Michael
Michael

Reputation: 13616

why bin folder not exists inside wwwroot in my project?

I created empty project asp.net 5 in Visual Studio 2015.

Here how it looks:

enter image description here

As I understand from some tutorials the bin folder have to be inside wwwroot.

But there is no bin inside wwwroot and also bin folder not exists anywhere in Sensor Observation project.

Any idea why bin folder not exists inside wwwroot in my project?

Upvotes: 3

Views: 2643

Answers (2)

Tseng
Tseng

Reputation: 64131

The wwwroot/bin folder only used to contain one single file AspNet.Loader.dll. The AspNet.Loader.dll was/is used by IIS to load the application (which resides outside of the wwwroot folder).

The reason for this is an increase of security. With ASP.NET Core 1.0 you don't point the application entry to the folder (that contained all the *.cs files in ASP.NET 4.5), but you point it to the wwwroot folder of your application.

Now IIS don't has access to the actual application files (and allow by accidental access to maybe sensitive files). So the AspNet.Loader.dll is required to execute your application.

Other than that, there are no other binary files in wwwroot/bin nor should there be any other.

Update:

This used to be required for Helios to be run/hosted within IIS. Helios has been deprecated with beta8, because it made no sense to develop two different servers. So wwwroot/bin will always be empty for newer versions of ASP.NET Core. If you found posts or references, they most likely reference to an old beta.

Now Kestrel, IIS via HttpPlatformhandler (up to rc1-final version and ASP.NET Core Module with rc2 and newer) and self-hosting via HttpListener are the supported run modes. Though one can also use Kestrel behind an IIS.

Upvotes: 2

Colin Mackay
Colin Mackay

Reputation: 19175

The wwwroot folder is from where you serve static files (e.g. css, images, JavaScript, etc.). Files in the bin folder should never be served to the client (e.g. browser) so it should not go in the wwwroot folder.

Here is some more information on what the wwwroot should contain. Essentially:

"Enter the wwwroot folder in ASP.NET 5. The wwwroot folder represents the actual root of the web app when running on a web server. Static files, like appsettings.json, which are not located in wwwroot will never be accessible, and there is no need to create special rules to block access to sensitive files. Instead of blacklisting access to sensitive files, a more secure whitelist approach is taken whereby only those files in the wwwroot folder are accessible via web requests."

Upvotes: 4

Related Questions