开发者

C# WebClient DownloadData issue on double quotes

开发者 https://www.devze.com 2023-02-23 01:05 出处:网络
Im making a request to a url, but in the returned string i get foreach \" an \\\" This is my code: WebClient webclient = new WebClient();

Im making a request to a url, but in the returned string i get foreach " an \"

This is my code:

WebClient webclient = new WebClient();
byte[] databuffer = webclient.DownloadData(url);
return Encoding.UTF8.GetString(databuffer);

What could be the problem to return as content of the webpage for instance:

<div id=\"whatever\">开发者_如何学Go instead <div id="whatever">?


There's no problem, you are probably looking the result in Visual Studio Debugger which does this. The actual string you are getting doesn't have any \". Try saving it to a file and you will see:

File.WriteAllBytes(@"c:\test.htm", databuffer);

So no worries, unless the web page you are downloading is crap and is using \" instead of " in the response.

0

精彩评论

暂无评论...
验证码 换一张
取 消