469,611 Members | 2,001 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,611 developers. It's quick & easy.

Set user agent header with webrequest

Hi,

I'm using webrequest to scrape some urls, works fine, however one url seems
to be throwing an error when it doesn't recognise the user agent. So I need
to set the user agent to something like MSIE, I've tried these
WebRequest.Headers.Set("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1;)")
WebRequest.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1;)")
WebRequest.Headers.Item("User-Agent") = "Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1; )")
and they all give the same error "System.ArgumentException: This header must
be modified with the appropriate property"

What's the correct way to set the User Agent header?

Cheers,
Jon
Nov 18 '05 #1
1 11177

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Erik | last post: by
7 posts views Thread by Fuzzyman | last post: by
60 posts views Thread by Fotios | last post: by
3 posts views Thread by Allerdyce.John | last post: by
reply views Thread by Jennyfer Barco | last post: by
reply views Thread by =?Utf-8?B?TWlrZTEz?= | last post: by
reply views Thread by =?Utf-8?B?TWlrZTEz?= | last post: by
35 posts views Thread by RobG | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.