\n <modules runAllManagedModulesForAllRequests=\"true\"/>\n</system.webServer>\n\n\n
3. add assembly reference in web.config:\n
\n<compilation defaultLanguage=\"c#\" debug=\"false\" targetFramework=\"4.0\">\n <assemblies>\n <add assembly=\"System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>\n <add assembly=\"System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>\n <add assembly=\"System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>\n <add assembly=\"System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>\n <add assembly=\"System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>\n </assemblies>\n</compilation>\n
\n4. add routes map in Global.asax,such as:\n\n\npublic static void RegisterRoutes(RouteCollection routes)\n{\n routes.IgnoreRoute(\"{resource}.axd/{*pathInfo}\");\n routes.MapRoute(\n \"Default\", // Route name\n \"{controller}/{action}/{id}\", // URL with parameters\n new { controller = \"Home\", action = \"Index\", id = \"\" } // Parameter defaults\n );\n}\n\nprotected void Application_Start()\n{\n RegisterRoutes(RouteTable.Routes);\n}\n
\n","author":{"@type":"Person","name":"artwl"},"upvoteCount":2}}}Reputation: 43
I've searched the archives and also googled about it but it seems I can't find a guide / best practices / how-to on how to smoothly add features to an existing ASP.net 4 website, adding them in the latest MVC. I have a website that was built with ASP.net 1.0 and progressively has been upgraded to 4.0, now I want to switch to MVC but re-create all the website in MVC is a too long process since the site has a lot of features, and some parts are just good in webforms. The best way for me should be to be able to smoothly add MVC to this existing ASP.net 4.0 website and progressively migrate the existing webforms to MVC.
(Don't want to start a webforms-MVC flame, just looking on some tips on how to avoid common mistakes.)
Upvotes: 4
Views: 1781
Reputation: 3582
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
3. add assembly reference in web.config:
<compilation defaultLanguage="c#" debug="false" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
4. add routes map in Global.asax,such as:
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 = "" } // Parameter defaults
);
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
Upvotes: 2