Free Web Development Online Tutorials, Learn to Code
Learn Asp.net Core, Free Asp.net Core Tutorial for Beginners, wwwroot folder in Asp.net core, Razor Page

wwwroot directory in Asp.net Core

"wwwwroot" folder in asp.net core is for all static files like css, images, javascript etc.

what is wwwroot folder in asp.net core?

When we create any Asp.Net Core project, the wwwroot folder is created by default, this folder is basically for all types of static files like html, css, js, images etc.

Any other type of ASP.NET applications we can store any static files in root, or in any other folder under root, and can be served from there. This has been changed in ASP.NET Core. Now we can store any static files under wwwroot folder only, all other files are blocked on http request.

wwwroot folder in asp.net core

As you can see in above picture, when we created the project a wwwroot folder was added automatically, now when we wanted add one static html file in project.

So for some experiment we have added two files in to two different locations.

  • one under wwwroot=>html=>policy.html
  • application root => test.html

Now let's try to access both the files from your virtual folder by accessing following path

address result
www.yourdomain.com/html/policy.html Works fine
www.yourdomain.com/wwwroot/html/policy.html Won't work
www.yourdomain.com/test.html Won't work

So, hope you understood the use of wwwroot folder, any type of static file that you want to be served on browser, to be placed under wwwroot only.


Comment
Name
Email
Website
Subscribe
 

hire remote asp.net developer
wwwroot directory in ASP.NET Core

ASP.NET MVC Interview Questions Answers

Asp.Net Core C# Examples | Join Asp.Net MVC Course