简体   繁体   中英

Why don't I have Routes.MapRoute in global.asax in an MVC project?

I have a problem with setting default route in my Asp.net MVC project. My global.asax doesn't have Routes.MapRoute , it just has the code bellow:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;

namespace razor
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
    }
}

Since the introduction of ASP.NET MVC 4 with Areas, etc. they were all moved to the RouteConfig.RegisterRoutes method. So go there and change your routes!

You can find that class in the RouteConfig.cs file in your App_Start folder.

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