Search code examples
c#asp.netasp.net-coreasp.net5

How to use UseStaticFiles in ASP.NET Core 1.0


I can't find many proper Core 1.0 tutorials yet, but when I google the method name, I get umpteen examples that say to include in Startup.cs:

app.UseDefaultFiles();
app.UseStaticFiles();

Yet I get compile errors that neither method exists on app, which is type IApplicationBuilder. Are these calls no longer required, or named totally different, or set somewhere else?


Solution

  • in your project.json make sure you have a reference

    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final"
    

    in RC2 that will likely need to change to Microsoft.AspNetCore.StaticFiles

    then you should be able to use

    app.UseStaticFiles();