473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to specify the browser to use in HttpWebRequest

2
I want different browsers to be used in HttpWebRequest.Will httprequest.UserAgent = "Mozilla/3.0 (compatible; Mozilla/5.0)"; do this for me?If i want to use IE what am i supposed to change in the above code?
Nov 3 '06 #1
1 1768
You need to set the User-Agent HTTP header for your request. You can easily do this as follows (there is a property which directly supports this):

objMyRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";

where objMyRequest is of type HttpWebRequest.

Set this before you write to the request stream or get the response. I can highly recommend using the Async methods as well for REALLY good performance. Check out the BeginGetResponse method on MSDN for a decent example.

I am using ASP.NET 2.0 Async pages with Async reading of the response and it is shockingly fast.

This is for IE 7. For IE 6 you can change this accordingly. I also have 1.1 and 2.0 of the CLRs installed as you can see.

Thanks,
Damon Carr
Nov 3 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dan Battagin | last post by:
Is there a known bug with the interaction between the HttpWebRequest and the ThreadPool? I current spawn several HttpWebRequest's using BeginGetResponse, and they work for a while, using worker...
9
by: Mike Cronin via DotNetMonster.com | last post by:
Hi there, Can anyone tell me what level of encryption is used when making an HTTPS POST request through an instance of the System.Net.HttpWebRequest object? Thanks much in advance! Mike...
4
by: _max_ | last post by:
HttpWebRequest() allows 'pseudo-browser' simulation to intercept incoming HTML for 'screen scraping', etc. But how would you do the opposite: Programmatically find out what a browser is sending...
5
by: _BNC | last post by:
I need to do the equivalent of 'select all' and 'capture' on a browser screen. I just want the text as it appears on-screen. Is there a simple way to automate this? The thing that may make it...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
1
by: Alex | last post by:
Hi, My case is simple: I use a httpwebrequest to authenticate to a web site (using POST method) and I get the auth cookie in a cookiecontainer. I can then re-use this cookie container to make...
0
by: Morgan Cheng | last post by:
To add HTTP Basic/Digest authentication to HttpWebRequest, I can use NetworkCredential, HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.del.icio.us/v1/tags/ get");...
0
by: etnaelk | last post by:
Hi all, I have a real bugger of a problem that I just haven't been able to figure out. I am working on writing my own proxy server in C# using TcpListener, TcpClient, HttpWebRequest/Response and...
1
by: Proogeren | last post by:
I have a problem with a httpwebrequest that I am creating. The request in itself looks correct but using fiddler I see that a www-authentication header is sent along as well. The code is pasted...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.