Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What files should go in the ASP.NET MVC Content folder?

Tags:

asp.net-mvc

I see that ASP.NET MVC generates a Content folder by default, which stores the site.css file. I have a site that uses some image files and XML files in order to do its job, yet I do not want to have those files as embedded resources. Should I just put the files in the solution within the content folder? Should I turn off the "Do not copy" build option on each resource since I will need to deploy the files to the website? Or should these files not even live in the solution and be loaded from the file system?

like image 645
Rob Packwood Avatar asked Jun 26 '11 21:06

Rob Packwood


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 are the files in MVC?

An MVC file is a compiled script used by Miva Merchant Empresa, a web server application used to run Miva-based web programs. It contains a module or web application that has been compiled from an . MV file. MVC files are often used for deploying e-commerce programs on the web.

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.

What is the folder structure of ASP.NET MVC?

The Views folder contains a subfolder for each Controller and Views for the Controller action results. The View's sub folder is named with the controller-name-prefix and View is named with the controller action. The Views folder contains a Web. config file.


1 Answers

It's a good approach to add all your files/resources to the solution (at least you can see them in VS ;-) Other developers won't be surprised that your solution really needs some other files.

If those files are the 'content' of your website (like css files) then you can store them in the Content folder. It is up to you what folder structure you come up with. For example you might want to store your images in folder related to the modules of your application, or just all in the images folder. MVC doesn't enforce any particular way of keeping your resource files.

Just leave the Build Action set to Content and Copy to Output Directory to 'Do not copy'.

You might want to take a look at T4MVC project (also available as NuGet package) which will help you in keeping urls to your images / files compile-time safe.

like image 70
Jakub Konecki Avatar answered Sep 21 '22 13:09

Jakub Konecki