mvc iis设置默认首页无效

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36535245/article/details/78877370

配置网站默认页index无效,在网上找了好久没有一个可以解决的方法,后来发现一个很低端的错误

。。。。

MVC的路由机制忘记弄了,可能因为mvc的路由导致iis默认首页加载不到

所以mvc的iis默认首页配置无效就需要改mvc项目路由控制器名

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

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

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                //controller默认加载控制器,action默认加载页面
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}
就是如此简单就成功了,同志们要好好学习啊

猜你喜欢

转载自blog.csdn.net/qq_36535245/article/details/78877370