Wednesday, 15 June 2011

razor - Url.Content doesn't work in ASP.NET MVC 5 -



razor - Url.Content doesn't work in ASP.NET MVC 5 -

i have images stored in content/images folder. want utilize 1 of them background in css. found in net should utilize url.content("~/content/images") reference files.

i wrote this:

#main_background { background-image: url('@url.content("~content/images/background_car.png")'); background-repeat: no-repeat; position: absolute; width: 100%; height: 100%; }

and in bundles' config file:

bundles.add(new stylebundle("~/content/layout_css").include("~/content/layout.css"));

when preview html code in chrome's view:source see nil parsed @ all. css looks same above.

later tried alter for:

#main_background { background-image: url('images/background_car.png'); background-repeat: no-repeat; position: absolute; width: 100%; height: 100%; }

and in bundle:

bundles.add(new stylebundle("~/content/layout_css").include("~/content/layout.css", new cssrewriteurltransform()));

it started working, saw in articles should utilize 1st method. why have problems it? isn't razor engine obliged parse url.content references?

you can't utilize razor syntax in css, never work.

asp.net razor asp.net-mvc-5

No comments:

Post a Comment