![](/img/trans.png)
[英]Can ASP.NET MVC routing and a classic ASP homepage (VBScript, not web forms) play together nicely?
[英]Routing in a hybrid app that is classic ASP.Net web forms and MVC
我继承了既是经典的asp.net Web窗体又是MVC(从Web窗体项目开始)的应用程序。 我想像MVC一样设置路由。 去这里最好的方法是什么? 我所需要的只是朝正确方向推进。
我知道如何通过global.asa> App_Start> Route Config和区域注册CS文件为仅MVC项目设置路由。
环境:
VS 2012,IIS 7,ASP.NET 4.0,经典的ASP.NET Web表单和MVC 4。
我的想法:
我正在考虑做以下事情,你们在这里看到问题了吗? 我可能最终会遇到一些web.config问题,但是目前我不确定这些问题会是什么。 我需要您的建议以在此处正确设置结构。
全局文件添加:
protected void Application_Start()
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
App_Start> RouteConfig.cs
namespace My.Site
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "My.Site.Controllers" }
);
OTHER ROUTES WILL GO HERE, THESE MAY REDIRECT TO a webform page or to a controller action.
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.