Set index.html as the default page

后端 未结 5 708
闹比i
闹比i 2020-12-29 20:07

I have an empty ASP.NET application and I added an index.html file. I want to set the index.html as default page for the site.

I have tried to right click on the ind

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 21:01

    Create a new controller DefaultController. In index action, i wrote one line redirect:

    return Redirect("~/index.html")
    

    In RouteConfig.cs, change controller="Default" for the route.

     routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Default", action = "Index", id = UrlParameter.Optional }
            );
    

提交回复
热议问题