我刚刚使用Razor引擎创建了一个新的ASP.NET MVC 3项目.我在控制器文件夹中添加了一个控制器,然后在homController.cs中添加了一个视图.
View(index.cshtml)只有这个代码:
@{ ViewBag.Title = "Home"; } <h2>Home</h2>
Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed,had its name changed,or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: / Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225
有什么问题?
解决方法
你能检查App_Start / RouteConfig.cs,你必须有一个名为homController.cs的控制器的代码:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default",url: "{controller}/{action}/{id}",defaults: new { controller = "hom",action = "Index",id = UrlParameter.Optional } ); }