简体   繁体   中英

C# download HTML page to string asp.net

I'm trying to download a aspx page's html from an another page, using the following code:

  WebClient webClient = new WebClient();
             String CompleteReport = webClient.DownloadString(new System.Uri(reportURL));

however the HTML that is returned contains the markup similar to the following:

"\r\n\r\n<!DOCTYPE html>\r\n\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head><meta charset=\"utf-8\" 

what should i do to download a string without these escape sequences.

Thank You!

The string doesn't actually contain those sequences. It contains the characters that they represent (actual newline and linefeed characters).

You are probably viewing the string in a debugger and the debugger is adding those sequences for you. If you dump it to a file and read it in notepad they won't be there.

See also this answer . If you add ,nq to the variable name in the watch window, the escape sequences will go away.

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