新建area区域
1.如果与根目录下的url相同,那么需要在RouteConfig.cs中
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "MvcApplication1.Controllers" }加上对应的namespaces参数
命名空间 你的项目的名字
);
}
2.Area区域指向其他地方的链接:
<div>
<h1>admin reaa Index</h1>
指向当前区域的链接
@Html.ActionLink("本区域","About")
<a href="/Admin/Home/About">Click me</a>
指向其他(Support)区域的链接
@Html.ActionLink("其他区域", "Index", new { area="Support"})
<a href="/Support/Home/Index">Click me to go to another area</a>
指向根目录下的链接
@Html.ActionLink("abc", "Index", new { area=""})
<a href="/Home/Index">Click me to go to top-level part</a>
1.</div>