ASP. NET MVC 3.0 Knowledge Point collation-----(3). ASP. NET MVC 3 and ASP 4 comparison

Source: Internet
Author: User

Tags: des style blog color using strong

The version of ASP. NET MVC is updated very quickly, and each version is built on the previous version to optimize performance and improve functionality.

Below, I compare the next two versions and find the most basic differences. (In the Update supplement: )

I. About the different configuration class global.asax

  To reduce the clutter of the configuration class, ASP. NET MVC 4 will separate the contents of the Global.asax file into several configuration files under App_start.

in ASP. NET MVC 3:

 Public Static voidregisterglobalfilters (globalfiltercollection filters) {filters. ADD (NewHandleerrorattribute ());}
//set up Routes Public Static voidregisterroutes (routecollection routes) {routes. Ignoreroute ("{Resource}.axd/{*pathinfo}"); Routes. MapRoute ("Default",//Route name "{Controller}/{action}/{id}",//route matching format, default URL New{controller ="Home", action ="Index", id = urlparameter.optional}//Default Parameters );}protected voidApplication_Start () {arearegistration.registerallareas (); //Use LocalDB for Entity Framework by defaultDatabase.defaultconnectionfactory =NewSqlconnectionfactory (@"Data source= (localdb) \v11.0; Integrated security=true; Multipleactiveresultsets=true"); Registerglobalfilters (globalfilters.filters); RegisterRoutes (routetable.routes); BootstrapSupport.BootstrapBundleConfig.RegisterBundles (System.Web.Optimization.BundleTable.Bundles); BootstrapMvcSample.ExampleLayoutsRouteConfig.RegisterRoutes (routetable.routes);}

in ASP. NET MVC 4:

protected void Application_Start () {    arearegistration.registerallareas ();    webapiconfig. Register (globalconfiguration.configuration);    filterconfig. Registerglobalfilters (globalfilters.filters);    routeconfig. RegisterRoutes (routetable.routes);    bundleconfig. Registerbundles (bundletable.bundles);}

Where the config file is used separately in the App_start folder.

WebApiConfig.cs:  filterconfig.cs :   routeconfig.cs:  Bundleconfig.cs:  related to bundling and narrowing of register Bundles, default CSS and JS, and so on.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: