Giving route or Migrating ASP.net Web Form to ASP.net MVC?

冷暖自知 提交于 2020-01-06 04:46:29

问题


I have a full web form application and want to migrate to MVC, before starting that I have been trying to implement The club site http://www.asp.net/downloads/starter-kits/extended-club using the instruction of Rob Conery, Scott Hanselman, Phil Haack in the book of Professional ASP.net MVC 2 in Chapter 12 . http://media.wiley.com/assets/1539/15/professionalaspnet35mvc_chapter13.pdf

I've created a folder for web form site, modified the Site.Master in shared folder using the web form master-page code and the result looks like:

According to the instructions I have to add routing to the site in Global.asax where I have tried many mapping route functions like:

  routes.MapRoute(
           "news", // Route name
           "{controller}/{action}/{id}", // URL with parameters
           new { controller = "News", action = "Index", id = UrlParameter.Optional } // Parameter defaults
       );


        routes.MapPageRoute(
  "mvchome",
  "home/index/{id}",
  "~/ClubSite/News_List.aspx"
  );

But no changes. Have I missed something in before jumping to routes (Global.asax) or the solution is in giving the proper route or proper routes to all web forms pages?


回答1:


The first route matches ANY route, it is essentially a wildcard route. Place your other route BEFORE that route and it will be recognised.



来源:https://stackoverflow.com/questions/6879433/giving-route-or-migrating-asp-net-web-form-to-asp-net-mvc

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