Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placing MVC Content folder into Area

First of all, I do understand, that MVC 3 default template's Content folder is not a mandatory css/img/etc. store folder.

I still like the concept of Content folder to be a "reference-able" storage location for images and style sheets and other possible stuff (I also place entire jQuery custom controls into Content's sub folders with .js files in them).

I haven't used MVC Areas thus far in my projects, since I didn't have a complex enough one's. Now it's time.

And I am thinking about placing a separate Content folder in each Area. Will it work? Is there something "bad" that can turn out of it? Like me not being able to reference resources in it via ../Content/MyControl? Or is MVC Area just like a root of the project, but a separate one?

like image 692
Maxim V. Pavlov Avatar asked Apr 05 '12 17:04

Maxim V. Pavlov


1 Answers

The area is almost just like a separate project (but not really). You can either use

Url.Content("~/Areas/AreaName/Content/FileInfo");

or

<link type="text/css" src="RootOfSiteInfo/Areas/AreaName/Content/FileInfo"/>

There should not be any issues not being able to reach the static content, though personally I leave everything in the root content folder (single point of storage) since many times CSS and the likes are shared in our projects across areas.

like image 90
Tommy Avatar answered Sep 20 '22 19:09

Tommy