By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,682 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,682 IT Pros & Developers. It's quick & easy.

Set user agent header with webrequest

P: n/a

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?

Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

This discussion thread is closed

Replies have been disabled for this discussion.