I have below code for my routing for web forms and MVC.
MVC routing seems to be working fine but not the web form when I mix both.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("");
//MVC
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
//WebForms
routes.MapPageRoute(
"myPage",
"page/companyInfo/{*queryvalues}",
"~/company/details.aspx"
);
Do I need to write a IgnoreRoute statement for details.aspx page?
Change the order of the routes, the MVC route should be at the bottom as default is basically a catch-all. MVC process routes from top to bottom, if it finds a match, it stops looking and routes you to the matched route.
//WebForms
routes.MapPageRoute(
"myPage",
"page/companyInfo/{*queryvalues}",
"~/company/details.aspx"
);
//MVC
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);