Tuesday, March 24, 2015

Add MVC into webforms project

Install below nuget pacakges

1) Microsoft ASP.NET MVC
2) WebGrease
3) Modify web.config or Add assembly of Abstractions, MVC and Routing 

4) Modify global.asax
Next you will need to add in the code for MVC triggers inside global.asax (create one if it does not exist)
Add the following lines after <%@ Application Language="C#" %>

<%@ Import Namespace="System.Web.Mvc" %> 
<%@ Import Namespace="System.Web.Routing" %>

Add the following after <script runat="server"

public void RegisterGlobalFilters(GlobalFilterCollection filters)
filters.Add(new HandleErrorAttribute());
public static void RegisterRoutes(RouteCollection routes)

new { controller = "Home", action = "Index", id = UrlParameter.Optional });}

add the following inside application_start


No comments: