How do I set the HttpRequestHeader for a HttpWebRequest?

Posted by Mr. Flibble on Stack Overflow See other posts from Stack Overflow or by Mr. Flibble
Published on 2010-03-18T15:02:55Z Indexed on 2010/03/18 15:11 UTC
Read the original article Hit count: 429

Filed under:
|

I'm trying to set the HttpRequestHeader for a HttpWebRequest like so:

new HttpWebRequest().Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0");

But I get an exception: System.ArgumentException: This header must be modified using the appropriate property.

How should I be setting the header?

© Stack Overflow or respective owner

Related posts about c#

Related posts about httpwebrequest