Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the Content folder sacred in asp.net mvc?

Tags:

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?

like image 959
BC. Avatar asked Feb 22 '09 19:02

BC.


People also ask

What is content folder in MVC?

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.

What is content folder in asp net?

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.

Which MVC folder of ASP Net is used for storing application data?

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.

Which is the default file is included in the views 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.


1 Answers

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.

like image 191
Matt Woodard Avatar answered Oct 13 '22 00:10

Matt Woodard