Asp.net
如何設置預設頁面asp.net [重複]
我剛剛在我的伺服器上發布了我的網站,但是當我在瀏覽器中鍵入 www.mysite.com 時,我收到了這個錯誤:HTTP 錯誤 403.14 - 禁止 Web 伺服器配置為不列出此目錄的內容。但是,如果我鍵入 www.mysite.com/Home.aspx 它會正確載入。那麼,如何設置預設頁面?我的 web.config 中已經有了這個:
<system.webServer> <defaultDocument> <files> <add value="Pages/Home.aspx" /> </files> </defaultDocument> </system.webServer>
ASP.NET Web 窗體
在
web.config文件上,嘗試使用clear之前的標籤:<system.webServer> <defaultDocument> <files> <clear /> <add value="Pages/Home.aspx" /> </files> </defaultDocument> </system.webServer>看看這裡:http ://www.iis.net/configreference/system.webserver/defaultdocument
ASP.NET MVC / ASP.NET 核心
根據您使用的 asp.net mvc 版本,您可以將它放在不同的文件中(
~/Global.asax.cs在 v3 或更早版本或~/App_Start/RouteConfig.csv4 或更高版本中)。在這兩種情況下,你都會看到註冊路由的東西,因為 asp.net mvc 使用路由而不是像 webforms 這樣的文件。因此,您可以更改預設值:public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", // default controller action = "Index", // default action on the controller id = UrlParameter.Optional } ); }它在ASP.NET CORE上類似。
看看這裡: http: //www.codeproject.com/Articles/624181/Routing-Basics-in-ASP-NET-MVC