ASP.Net MVC 4 Packages - Using Variables in Path Names

I am trying to create a dynamic css path similar to the path below, where "VARIABLE" changes depending on the runtime values ​​- using the MVC4 binding component.

Is there any way to do this?

<link rel="stylesheet" href="/assets/css/brand/VARIABLE/global/global.css"> 
+4
source share
1 answer

Is this exactly what you are looking for? The code below simply gets the theme configuration parameter value:

 public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new StyleBundle("/~Content/css"). Include(String.Format("~/Content/{0}/site.css", ConfigurationManager.AppSettings("theme")))); } 

In your opinion, just call Styles.Render :

 @Styles.Render("~/Content/css"); 

If you need to use values ​​other than configuration parameters, I think you will need a static method that returns the corresponding value.

+1
source

All Articles