Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27346

VS 2010 Can’t set WebClient Accept header

$
0
0
I’ve used HTTPWebRequest or WebRequest replete with all the stream readers and such to grab the HTML string of a web page. I was delighted to find the WebClient class which seems to encapsulate most that. I tried to implement it just now but needed to add headers for “UserAgent” and “Accept”. Doing it with HTTPWebRequest worked but not with WebClient. When I look at the headers in the WebClient object after setting them only the UserAgent was apparent and the count of the headers collection was 1. I read the documentation of WebCleint on the MSDN and it said that Accept and other headers are ‘restricted’. I think this means I can’t set Accept to "text/html, application/xhtml+xml, */*". Can someone confirm my understanding and that I can’t use WebClient in this case?

Also it’s my understanding that the default Accept header WebClient uses is “text/HTML”. Does this mean that if the object of my desires has programming on the HTML page it will not work? Which, in this case, it does.

Viewing all articles
Browse latest Browse all 27346

Trending Articles



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