加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 将index.html设置为默认页面

发布时间:2020-12-16 00:22:11 所属栏目:asp.Net 来源:网络整理
导读:我有一个空的ASP.NET应用程序,我添加了一个index.html文件。我想将index.html设置为网站的默认页面。 我试图右键单击index.html并设置为起始页,当我运行它时,url是:http:// localhost:5134 / index.html但是我真正想要的是当我键入:http: // localho
我有一个空的ASP.NET应用程序,我添加了一个index.html文件。我想将index.html设置为网站的默认页面。

我试图右键单击index.html并设置为起始页,当我运行它时,url是:http:// localhost:5134 / index.html但是我真正想要的是当我键入:http: // localhost:5134,它应该加载index.html页面。

我的路由配置:

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 }
            );
        }
    }

解决方法

我添加了一条指令给我的路由配置,以忽略空路由,这解决了我的问题。
routes.IgnoreRoute("");

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读