3

You know ASP .NET Core MVC has a wwwroot static files folder. I need to put my custom js, css etc. into Content folder under Areas folder. Anyone tried this before or anyone know how to do this?

1 Answer 1

4

If the structure of our area is as follows :

enter image description here

You need to Copy these codes to the Configure section in Startup under the app.UseStaticFiles()

app.UseStaticFiles(new StaticFileOptions()
   {
     FileProvider = new 
     PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), 
     "Areas\\Foo\\Content")),
      RequestPath = new PathString("/Foo/Content")
   });

and link the file like below :

 <link rel="stylesheet" href="/Foo/Content/bootstrap.min.css" />
Sign up to request clarification or add additional context in comments.

1 Comment

This approach worked for local testing - however when deployed to azure setting the script as Content didn't deploy. Under the azure environment the Directory.GetCurrentDirectory() is looking for file in wwwroot folder i.e. D:\home\site\wwwroot\Areas\Foo\Content\

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.