I want to use js/files outside wwwroot folder. How to Do that?
Asked
Active
Viewed 633 times
1
-
3Why not just move everything into `wwwroot`? – Ryan Wilson Dec 07 '18 at 14:56
1 Answers
2
Yes, you can serve static files outside wwwroot.
public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles(); // For the wwwroot folder
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "MyStaticFiles")),
RequestPath = "/StaticFiles"
});
}
See Serve files outside of web root.
But why do you want this?

Alexan
- 8,165
- 14
- 74
- 101
-
Like I said, I have migrating from mvc to MvcCore, and there are bunch of static files in that application. So I just though not to move those files. But is it good to move all files in wwwroot? I just concern about number of files and sizes that's all. – user2731553 Dec 10 '18 at 07:35
-
it depends. But actually you need some modification in your project migration to .NET Core, maybe spend some time to bring it to standard Core architecture. – Alexan Dec 11 '18 at 14:18