0
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?!

1
  • Please provide full path of request in error. It's possible that you are looking resource in wrong location. Again, without full trace, it's difficult to pinpoint problem Commented Mar 15, 2016 at 15:16

1 Answer 1

3

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")
    });
}
Sign up to request clarification or add additional context in comments.

2 Comments

I have it otherwise it would show an error and it won't compile
By default server will look into "wwwroot"folder for static files. Where are you storing your static files?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.