0

we currently have a big Webforms application thats currently running on 4.6 framework. We have the webforms routing already setup.

Now, we are trying to add MVC to this project and make it a hybrid application. But the problem comes when we try to use routing for both the Webforms as well as MVC views. Here is how

public static void RegisterRoutes(RouteCollection routes)
        {
            RouteTable.Routes.MapPageRoute("Test", "Test", "~/WebForm_Test.aspx");
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }

I am unable to use it this way because it keeps using the webforms route for everything. i have read a lot of blogs(by Scott hanselman, etc) but none of them mention how to use routing in parallel.

When i remove the routing for the webforms and just the MVC routing and using the ASPX pages just by redirecting to "~/Webform_test.aspx" it seems to work fine.

can someone please help me setup routing for both webforms as well as MVC ?

Thanks

Surya Garimella
  • 317
  • 4
  • 13
  • Possible duplicate of [How to route a .aspx page in asp.net mvc 3 project?](http://stackoverflow.com/questions/10175200/how-to-route-a-aspx-page-in-asp-net-mvc-3-project) – NightOwl888 Jan 20 '17 at 21:24
  • Not Really..!! i tried that approcach suggested by Vinicius Ottoni where he added another class called "MyCustomConstraint" but that didnt help. Because in my code after i register my routes i do Response.RedirectToRoute("BulletinBoard") But then it keeps giving another error saying "No matching route found for RedirectToRoute." which is strange. – Surya Garimella Jan 20 '17 at 21:52
  • Also, i cannot have a controller or for every webform that i already have. so i need to use the old routing using the "MapPageRoute" approach. Can someone please Help. – Surya Garimella Jan 20 '17 at 22:15
  • That is using "MapPageRoute" approach. The issue is that you need to add the constraint *to each MapPageRoute method call* in order to prevent it from matching your outgoing requests (like the one when you call `RedirectToRoute` - which BTW will only work you pass all of the route values for the route you are trying to match). – NightOwl888 Jan 23 '17 at 23:52

0 Answers0