【发布时间】:2011-07-04 22:07:34
【问题描述】:
我在我的 MVC 3 应用程序中创建了一个名为“博客”的区域。
在 global.asax 我有以下代码。
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
这是我所在区域的代码
public class BlogAreaRegistration : AreaRegistration
{
public override string AreaName
{
get { return "Blog"; }
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Blog_default",
"Blog/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
当我转到以下网址 http://localhost/CMS/blog 时,我收到以下错误。
未找到视图“索引”或其主视图,或者没有视图引擎支持搜索到的位置。搜索了以下位置: ~/Views/blog/Index.aspx ~/Views/blog/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx ~/Views/blog/Index.cshtml ~/Views/blog/Index.vbhtml ~/Views/Shared/Index.cshtml ~/Views/Shared/Index.vbhtml
我该如何解决这个问题?
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-3 c#-4.0