简体   繁体   中英

After saving ASPX page the URL's are broken. How can I save the full URL for images and CSS?

I have requirements to save an ASPX page to an HTML file for further use. The code below works perfectly and saves all the dynamic content on the page without issue. Where i ran into a problem is the header image link and the link to the CSS. Both are a partial path which produces a broken link. Is there a way I can have the page load/save using the full path to those items?

StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
string myPageHTML = null;
Statement stmtPage = new Statement();

Server.Execute("Statement.aspx", sw);

myPageHTML = sw.ToString();

Just be a little more clear on the results I'm seeing is after saving there is no domain and its the relative path without the domain. The images and CSS are hosted on the site so all I need is for the full path to save.

Can you add a <base> tag to your HTML? See here .

The HTML <base> element specifies the base URL to use for all relative URLs contained within a document.There is maximum one <base> element in a document.

怎么样这个

System.Net.WebClient().DownloadString(url)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM