一,当项目中存在多个网站报错,而不是新增Area出现这个错误时。应该在RouteConfig这样改:

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

namespace Houtai.Web.Mobile
{
    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[] { "Houtai.Web.Mobile.Controllers" }
            );
        }
    }
}

二,若是添加Area,造成的错误,则

 public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

           routes.MapRoute(  
                "Default", // 路由名称  
                "{controller}/{action}/{id}", // 带有参数的 URL  
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值  
                ,  new string[] { "Houtai.Web.Mobile.Controllers" }
            ); 
              
        }
    }

 

相关文章:

  • 2022-01-30
  • 2021-08-04
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2022-02-19
  • 2022-01-18
猜你喜欢
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案