我在global.asax
中有以下路由规则public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Profile", "Profile/", new { controller = "Home", action = "Profile", id = UrlParameter.Optional });
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
我不知道发生了什么,但现在默认的网址引发了以下错误:
The view at '~/index.cshtml' must derive from WebViewPage, or WebViewPage<TModel>.
[InvalidOperationException: The view at '~/index.cshtml' must derive from WebViewPage, or WebViewPage<TModel>.]
System.Web.Mvc.WebViewPage.ConfigurePage(WebPageBase parentPage) +180
System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +90
System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +12
System.Web.WebPages.WebPageBase.Write(HelperResult result) +80
System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +66
System.Web.WebPages.WebPageBase.PopContext() +279
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +98
System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContext context) +223
如果我转到http://www.mydomain.com/Home/它可以正常工作,但如果我转到http://www.mydomain.com/则会抛出上述错误。谢谢。
添加目录结构
Root
Models
Controllers
....
Views
Home
Account
....