是否提供路由或将ASP.net Web窗体迁移到ASP.net MVC? [英] Giving route or Migrating ASP.net Web Form to ASP.net MVC?

查看:86
本文介绍了是否提供路由或将ASP.net Web窗体迁移到ASP.net MVC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个完整的Web窗体应用程序,并且想要迁移到MVC,然后再开始尝试实施俱乐部网站 http://media.wiley.com/assets/1539/15/professionalaspnet35mvc_chapter13. pdf

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

我已经为Web窗体网站创建了一个文件夹,使用Web窗体母版页代码修改了共享文件夹中的Site.Master,结果如下:

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:

根据说明,我必须在Global.asax中添加到站点的路由,其中 我尝试了许多映射路由功能,例如:

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"
  );

但是没有变化.在跳转到路由(Global.asax)之前我是否错过了某些内容,或者解决方案是为所有Web表单页面提供正确的路由?

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?

推荐答案

第一个路由与ANY路由匹配,它本质上是通配符路由.将您的其他路线放置在该路线之前,该路线将被识别.

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

这篇关于是否提供路由或将ASP.net Web窗体迁移到ASP.net MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆