简体   繁体   中英

Route request for Home.aspx to a controller

This has likely been answered (perhaps multiple times) but I can't quite seem to figure it out from any of the posts I'm finding.

Our old website had a Home.aspx and there are still links out there that point to this page. So in our MVC site I want a route that will take incoming requests for Home.aspx and route it to a controller.

From what I can tell MapPageRoute seems to do the opposite by mapping a route to a page. How do I route a request for a physical page to a controller though?

This should map the route however you want it to:

routes.MapRoute(
    name: "SomeName",
    url: "Home.aspx",
    defaults: new { controller = "Controller", action = "Action", id = UrlParameter.Optional }
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM