Quantcast
Channel: HTML Renderer
Viewing all articles
Browse latest Browse all 693

New Post: External CSS background-image from external CSS stylesheet

$
0
0
I have a very simple HTML page I am pulling in through C# with this code:
string data = "";
string urlAddress = "http://127.0.0.1:81";
try
{
    using (WebClient client = new WebClient()) // WebClient class inherits IDisposable
    {
        data = client.DownloadString(urlAddress);
    }
    Image image = HtmlRenderer.HtmlRender.RenderToImage(data);
}
catch (WebException ex)
{
    //do something if load fails
}
The HTML page has two <link> tags referencing stylesheets with a full URI:
<link href="http://127.0.0.1:81/Content/globals.css" rel="stylesheet" media="screen" />
<link href="http://127.0.0.1:81/Content/themes/1/theme.css" rel="stylesheet" media="screen" />
Then, in the theme.css stylesheet, there is a very simple CSS style:
.outer-container { background-image: url('http://myurlhere.com/background-images/126266045.jpg'); background-repeat: repeat-y; }
No matter what, HTML Renderer will not render that image from the stylesheet. BUT, if I copy that CSS style to the HTML page itself (in between <style> tags) OR use that style inline, the background image is loaded.

Why will an external image not load from a CSS stylesheet?

Viewing all articles
Browse latest Browse all 693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>