<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove/>
<add path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>

</configuration>
感觉和默认的MVC5建立的出来的一样的,只是把版本号从5.0.0.0改为4.0.0.0了。。。
6.建立App_Start目录,里面建立FilterConfig.cs文件,内容:
using System.Web;
using System.Web.Mvc;
namespace WebApplication1
{
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
}
}
感觉好像没有这个文件也不要紧
7.App_Start目录中建立RouteConfig.cs文件,内容:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace WebApplication1
{
public class RouteConfig
{
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 }
);
}
}
}
要用到MVC的,这个文件是最主要的话,用到MVC的路由创建
8.项目根目录下建立Global.asax文件,在Application_Start中注册一下上面建立的二个类,主要内容:
protected void Application_Start(object sender, EventArgs e)
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
9.运行项目,就可以看到界面出来了,不过好像在CSHTML中的智能提示是没有的,不知道怎么弄,先这样吧!!!
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-64985-3.html
我发现一群喷子以喷为乐
看来台湾还是有清醒脑筋的聪明人
一定会去看的
帅的没谁了