Is the Content folder special to the underlying framework of MVC? I can't find any reference to it in routing code or configuration.
I'm just wondering if static content can be handled in different ways.
On a related note, stackoverflow's script and css content seems to be retrieved by version number in the querystring:
<link href="/Content/all.min.css?v=2516" rel="stylesheet" type="text/css" />
Care to speculate how this might work and why this would be important?
The Content folder of an MVC application is used to store the static files such as the image files, CSS files, and icons files. When we create an MVC 5 application, by default the bootstrap. css, bootstrap.
In the general web asp.net project, the application just recognizes certain folder names that you can use for specific types of content. The following link provides us a detailed introduction about the name list. According this article we could know the “Content” folder is not one of them.
The App_Data folder of an ASP.NET MVC application contains application-related data files like . mdf files, LocalDB, and XML files, etc. The most important point that you need to remember is IIS is never going to serve files from this App_Data folder.
Views. The Views folder contains HTML files for the application. Typically view file is a . cshtml file where you write HTML and C# or VB.NET code.
No magic, the System.Web.Routing.RouteCollection class has a property RouteExistingFiles which controls the behavior.
The default is false, which means ASP Routing should not route the URL, but just return the default content. In this case the "/Content/all.min.css?v=251" skips the MVC routing rules entirely.
if you want to add a routing rule for the content folder, you need to add the rule, and set RouteExistingFiles to true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With