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

2019-09-16 06:51发布

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: the club site image

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条回答
等我变得足够好
2楼-- · 2019-09-16 07:27

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

查看更多
登录 后发表回答