我有一个mvc项目。在项目中,我添加名称的新区域BEK 它创建BEKAreaRegistration.cs本身将区域添加到mvc项目
public class BEKAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "BEK";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"BEK_default",
"BEK/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
和我的Global.asax文件是如下
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
RouteTable.Routes.IgnoreRoute("{*allAspx}", new { allAspx = @".*\.aspx(/.*)?" });
RouteTable.Routes.IgnoreRoute("{*allAsmx}", new { allAsmx = @".*\.asmx(/.*)?" });
RouteTable.Routes.IgnoreRoute("{*allAshx}", new { allAshx = @".*\.ashx(/.*)?" });
RouteTable.Routes.IgnoreRoute("Services/{*pathInfo}");
RouteTable.Routes.IgnoreRoute("");
RouteTable.Routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
但是当我试图转到BEK /主页/索引页面我得到错误页面。我还应该做什么
无法找到资源。 描述:HTTP 404.您正在查找的资源(或其某个依赖项)可能已被删除,名称已更改或暂时不可用。请检查以下网址并确保它拼写正确。
请求的URL:/ LMS_WEB_APP/BEK /主页
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.18213
这是我想的问题是,你有两个区和应用同名控制器的方式
,当我把断点到这条线就嗟这是问题是不是这个 – brtb
可以请你,邮政您的错误信息! –
我为它坏的粘贴而感到抱歉 – brtb