I create new asp.net mvc project in visual studio 2015.The project has a wwwroot file.What is this?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Quoting the official website:
Source
It's worth mentioning that the term
wwwroot
itself is certainly not new and it's actually a convention used across many platforms (including J2EE applications and IIS itself with itsc:\inetpub\wwwroot
directory).Similar conventions in the Unix/Linux world are
htdocs
,public_html
andwww
.The
wwwroot
folder is new inASP.NET 5
to storeall of the static files in your project. Any files including HTML files, CSS files, image files, and JavaScript files which are sent to the users browser should be stored inside this folder
.Code files should be placed outside of
wwwroot
including C# files and Razor views. Having awwwroot
folder keeps a clean separation between code files and static files, it brings clarity to the items that will be sent to the server and the items that should remain on the dev machine. If you look at figure,wwwroot
folder has css and lib sub folders. Css folder is a place to keep your custom css files, while lib folder is used by Bower package manger. The lib folder contains the packages downloaded by Bower and can contain css,js and images.Figure shows that lib folder has a bootstrap package folder, if you expand it you will find css, js as well all other assets related to the boostrap package.
In
MVC4
we used the content folder to keep style sheets as well as scripts folder for referenced scripts, these folders are gone now. So its important to understand that there is no single folder for style sheets or scripts. the could be in any of the folders withinwwwroot
.Its interesting to note that if you wish to reference the css,js or img files in your razor views, using the ~ keyword ensures direct path to the
wwwroot
folder. So suppose you wanted to reference site.css in your view you can access it using the<link rel="stylesheet" href="~/css/site.css" />
syntax.You can see that the
~
keyword points to thewwwroot
folder.