ma1169
ma1169

Reputation: 1158

linking Custom CSS to MVC6

Failed to load resource: the server responded with a status of 404 (Not Found)

I'm using MVS 2015 in web mode debugging and i have

  app.UseStaticFiles();

and i'm using Common HTTP features so what's wrong?!

Upvotes: 0

Views: 78

Answers (1)

Saleem
Saleem

Reputation: 8988

You'll need dependencies in your project.json.

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

Note: ASP.net MVC by default look into wwwroot folder for static content. However, if you want to change it, you'll need to override it into Startup.cs

var staticContentFolder = new DirectoryInfo(env.WebRootPath).Parent;
if (staticContentFolder != null)
{
    app.UseStaticFiles(new StaticFileOptions()
    {
        FileProvider = new PhysicalFileProvider(
            Path.Combine(staticContentFolder.FullName, "Contents")),
        RequestPath = new PathString("/Contents")
    });
}

Upvotes: 3

Related Questions