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

后端 未结 1 1705
情书的邮戳
情书的邮戳 2021-01-17 01:20

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条回答
  • 2021-01-17 01:58

    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

    0 讨论(0)
提交回复
热议问题