c# WebRequest class and headers
Posted
by Sir Psycho
on Stack Overflow
See other posts from Stack Overflow
or by Sir Psycho
Published on 2008-10-27T12:32:02Z
Indexed on
2010/03/08
23:51 UTC
Read the original article
Hit count: 503
Hi,
When I try to set the header properties on a WebRequest object, I get the following exception
This header must be modified using the appropriate property
I've tried modifying the .Headers propery and adding them that way like so
webRequest.Headers.Add(HttpRequestHeader.Referer, "http://stackoverflow.com");
But still getting exceptions. I can get around this by casting the WebRequest object to a HttpWebRequest and setting the properties such as httpWebReq.Referer ="http://stackoverflow.com"
But I'd like to know if there's a way to get a finer grained control over modifying headers with a request for a remote resource.
Thanks
© Stack Overflow or respective owner