Some background:
I create a new ASP.NET MVC 3 WebApplication.
Then I add a Webforms page: ~/ASPWebforms/Test.aspx
Then I edit the routing in the Global.asax file like this:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapPageRoute("Test", "Test/", "~/ASPWebforms/Test.aspx");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Now I type in my browser http://localhost:54847/Test and everything works as expected.
The problem is that all other links look like that: http://localhost:54847/Test?action=Index&controller=Home
I also tried to change the order of the routes:
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 = UrlParameter.Optional }
);
routes.MapPageRoute("Test", "Test/", "~/ASPWebforms/Test.aspx");
}
but then http://localhost:54847/Test won’t work anymore.
I’m expecting the link http://localhost:54874/Test to go to ~/ASPWebforms/Test.aspx
And the other links work as usual mvc style {controller}/{action}/{id}
Thx for your help!
I found a solution for the first problem on this page:
http://forums.asp.net/p/1589809/4028028.aspx
An interesting sentence from this page: