Reputation: 68750
We are re-writing an old asp.net site into MVC4.
There are many links to our site that look like this (that we don't control but must support):
www.some.com/page.aspx?id=5
Is there a way to get a request for /page.aspx?id=5 into a Route so that we can handle the request, pass it to a controller/action and then handle it from there?
Upvotes: 3
Views: 3902
Reputation: 255
Check out, you might also introduce "areas" to your app - it's helpful if your project is big enough. And if you use them, they will reflect on your routes.
Upvotes: 0
Reputation: 7943
In the RouteConfig, add a route (before default route):
routes.MapRoute(
name: "DefaultAspx",
url: "page.aspx",
defaults: new { controller = "MyAspxPage", action = "Index", id = UrlParameter.Optional }
);
In the controller catch the page id:
(MyAspxPageController)
public ActionResult Index(int id)
{
// Do whatever needed
//return View();
}
Upvotes: 6