开发者

Link to a root controller from area controller in ASP MVC

开发者 https://www.devze.com 2022-12-18 03:27 出处:网络
How can I link to one of my root controllers from one of my areas? <% Html.RenderAction(\"Action\", \"Page\", new {area = \"root\", name = \"Admin\"}); %>

How can I link to one of my root controllers from one of my areas?

<% Html.RenderAction("Action", "Page", new {area = "root", name = "Admin"}); %>

This gives me an error:

No route in the route table matches the supplied values.

I have a controller named Pagein a folder named 开发者_开发百科Admin in my root controller collection. I can reach this controller by typing \Admin\Page.

This is how I registered the route:

        routes.MapRoute(
            "Admin",
            "Admin/{controller}/{action}/{id}",
            new { controller = "Admin", action = "Index", id = "" }
        );

I was hoping I could address the "Admin" route using this syntax in my view, but that did not work. Any ideas on how to fix it?


<% Html.RenderAction("Action", "Controller", new { area = "" }); %>
0

精彩评论

暂无评论...
验证码 换一张
取 消