0

I'm trying to move default MVC directories structure to a new one to manage something like themes. This is how the directory structure would be.

<root>\
<root>\Themes\
<root>\Themes\theme01
<root>\Themes\theme01\content\*.css
<root>\Themes\theme01\scripts\*.js
<root>\Themes\theme01\Views\
<root>\Themes\theme01\Shared\

I succeeded to change the default location of the Views following the steps indicated here How to change default view location scheme in ASP.NET MVC?

Now I need to know how I can change the way of resolving the root folder path in the .cshtml views without the need of specify a full path. For example, the css are referenced like this:

 <link type="text/css" rel="stylesheet" href="~/Content/default.css" />

~/Content will resolve as http://root/Content/default.css

but I need to be resolved internally as http://root/Themes/theme01/Content/default.css

Is there is a way to change that in MVC ? Thanks !

Community
  • 1
  • 1
tapatio
  • 387
  • 1
  • 4
  • 9
  • 2
    This sounds like a really painful mess and I'd move forward with caution. Note, if you are using bundles you can just modify how the bundle resolves and the url it resolves to. That said, I'd ask yourself if this is the right direction or if you are complicating things unnecessarily. Rather than change the root, you could use better routing and allow the controllers to drive the correct behavior. – David L Sep 21 '16 at 19:05
  • I second what @DavidL is saying. This sounds like a problem that would be better solved by changing your routing or using sub applications in IIS or similar. Hacking together something to change the default behavior is going to be very confusing to maintain in the future. – Matti Price Sep 21 '16 at 19:09
  • My objective is only to group presentation files as "themes", something like wordpress does. When I need to change the design, I would only add , for example, a "Themes\theme02" folder and set a variable in the config like actualTheme = "theme02". That would be for me less mess than having all css files in one folder like the ~/Content directory. – tapatio Sep 21 '16 at 19:26

0 Answers0