I have a very simple HTML page I am pulling in through C# with this code:
Why will an external image not load from a CSS stylesheet?
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?