I have the following CSS code in my style sheet: background-image:url("~/media/1003/kappe-kort.gif")
But in the generated style sheet sent to the server, the tilde is still there in literal form, cuasing the browser to look for /css/~/media/1003/kappe-kort.gif rather than /media/1003/kappe-kort.gif.
Using background-image:url("/media/1003/kappe-kort.gif") without the tilde works fine. But isn't the tilde version supposed to be more robust?
Umbraco 7.1.8 ASP.NET MVC 4 Windows 7 pro SP1 IIS 7
The ~/ root is a server side feature of .NET. In the HTML output from the server it will be replaced with the root application file path in HTML.
It is deemed more robust because it means your application could still work in a sub folder or root directory if required.
CSS is not run at the server side so you can't actually use the ~ in .css files. Stick with / and amend your CSS if the application is ever moved to a sub folder.
Tilde (~) does not work in CSS URL?
I have the following CSS code in my style sheet:
background-image:url("~/media/1003/kappe-kort.gif")
But in the generated style sheet sent to the server, the tilde is still there in literal form, cuasing the browser to look for /css/~/media/1003/kappe-kort.gif rather than /media/1003/kappe-kort.gif.
Using
background-image:url("/media/1003/kappe-kort.gif")
without the tilde works fine. But isn't the tilde version supposed to be more robust?
Umbraco 7.1.8
ASP.NET MVC 4
Windows 7 pro SP1
IIS 7
The ~/ root is a server side feature of .NET. In the HTML output from the server it will be replaced with the root application file path in HTML.
It is deemed more robust because it means your application could still work in a sub folder or root directory if required.
CSS is not run at the server side so you can't actually use the ~ in .css files. Stick with / and amend your CSS if the application is ever moved to a sub folder.
is working on a reply...