1

I want to use js/files outside wwwroot folder. How to Do that?

ekad
  • 14,436
  • 26
  • 44
  • 46

1 Answers1

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