2016-03-03 15 views
33

Utworzono pusty Zastosowanie WWW w .NET Core w wwwroot mam index.html, który nie jest załadowany jako domyślnej strony, ładuje tylko kiedy ja to nazywam wyraźnie.nie index.html pokazując jako startową

Oto moja project.json

{ 
    "version": "1.0.0-*", 
    "compilationOptions": { 
    "emitEntryPoint": true 
    }, 

    "dependencies": { 
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", 
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final" 
    }, 

    "commands": { 
    "web": "Microsoft.AspNet.Server.Kestrel" 
    }, 

    "frameworks": { 
    "dnxcore50": { } 
    }, 

    "exclude": [ 
    "wwwroot", 
    "node_modules" 
    ], 
    "publishExclude": [ 
    "**.user", 
    "**.vspscc" 
    ] 
} 

Oto moja Uruchomienie:

public class Startup 
{ 
    // This method gets called by the runtime. Use this method to add services to the container. 
    // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 
    public void ConfigureServices(IServiceCollection services) 
    { 
    } 

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 
    public void Configure(IApplicationBuilder app) 
    { 
     app.UseStaticFiles(); 
    } 

    // Entry point for the application. 
    public static void Main(string[] args) => WebApplication.Run<Startup>(args); 
} 

Odpowiedz

74

Trzeba dodać

app.UseDefaultFiles(); 

przed app.UseStaticFiles(); w Configure metody.

Aby uzyskać więcej informacji, zobacz documentation.

+0

Dobra! Masz rację. Działa i zamówienie odgrywa dużą rolę, co mi się nie podoba, ale ... – DAG

+3

Oto dodatkowe informacje. Na przykład biblioteka do dodania i kolejność. http://www.talkingdotnet.com/make-index-html-startup-file-in-aspnet-core/ –

+0

Czy jest strona, na której możemy zobaczyć, które oprogramowanie pośrednie musi zostać wywołane, kiedy? Lub po prostu google to wszystko ... – Legends

-5

Innym sposobem na to jest edycja pliku web.config. Dodaj nowe zasady, odpowiadające twoim potrzebom.

Powiązane problemy