简体   繁体   中英

Routing in a hybrid app that is classic ASP.Net web forms and MVC

i have inherited an application that is both clasic asp.net web forms and mvc (started as web forms project). I would like to setup routing like MVC. What is the best way to go here? All i need is a push in the right direction.

I know how to setup routing for the MVC only project via global.asa > App_Start > Route Config and area registration cs files.

Environment:

VS 2012, IIS 7, ASP.NET 4.0, classic asp.net web forms and MVC 4.

My thinking:

I am thinking about doing some thing like following, do you guys see an issue here? I may end up with some web.config issues but at this this time i am not sure what those would be. I need your advice to properly setup the structure here.

Global file addition:

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. 

            }




        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM