asp.net-mvc-5customizationaspnetboilerplatesystem.web.optimization

Set background image URL in CSS file to another site


I set a background image URL in CSS file to another site as below:

body.teaching {
    background: url("http://sample.com/beijing.png") no-repeat no-repeat;
    background-size: 100% 100%;
}

After I deploy to the server (e.g. www.foo.com), the URL changed like below (404 error):

http://www.foo.com/css/http:/sample.com/beijing.png

I think it is caused by CssRewriteUrlTransform, so my question is: What is the correct way to set the image URL to another site? I don't want to disable CssRewriteUrlTransform, because many other image URLs need to be transformed.


Solution

  • I extract the background url to another css and without applying CssRewriteUrlTransform, it works now