问题
I have a url Review.aspx?reviewId=3 and I'd like to have this url be routed to an MVC controller/action Review/3. Any ideas?
回答1:
Never mind, a simple route like this worked:
routes.MapRoute(
"Reviews_Old", // Route name
"LOreview.aspx", // URL with parameters
new { controller = "LOReview", action = "Review", id = UrlParameter.Optional } // Parameter defaults
);
And the query string parameters are model bound on the controller action parameters
来源:https://stackoverflow.com/questions/10590662/route-from-incoming-aspx-url-to-an-asp-net-mvc-controller-action