In normal WebForms scenario, any root-relative URLs (e.g. ~/folder/file.txt) inside CSS files such as:
.form { background-image: url(~/Content/I
I would not bother with the auto-root-finding ~
character. I understand that you want the same solution to work where the root directory differs between deployments, but within the CSS document you shouldn't have any problems using relative paths. The paths in the CSS document (to the image URL in your example) will always be relative to the location of the CSS file regardless of the path of any page that loads that CSS file. So if your images are in ~/Content/Images
and your stylesheets are in ~/Content/Stylesheets
, you'll always be able to use background-image: url(../Images/form_bg.gif);
and it will work regardless of the location of the page that loads the stylesheet.
Is there a reason this wouldn't work?