Route from Incoming ASPX url to an ASP.NET MVC Controller Action

会有一股神秘感。 提交于 2019-12-01 13:19:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!