ASP.NET MVC ActionLink outside area

為{幸葍}努か 提交于 2019-11-30 08:08:28

Try this :

<%= Html.ActionLink("Back", "Index", "Home", new { area = "" }, null) %> 

When using Areas, you should always specify the area your are calling in your ActionLinks by adding a route value as above, If the link is outside the area (as in your case), just use an empty parameter for the area.


There's a nice extension that i find essential in any ASP.NET MVC project (T4MVC). It makes your ActionLinks look much cleaner and it protects them against errors.

So the above code will look something like this :

<%= Html.ActionLink("Back", MVC.Home.Index()) %>

and when using an area :

<%= Html.ActionLink("Some Link", MVC.Admin.SomeController.SomeAction()) %>

It's a part of the MvcContrib project on codeplex here

You should consider using it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!