Last post Nov 06, 2009 07:45 AM by govdev
Nov 05, 2009 02:27 PM|govdev|LINK
I am developing an data migration tool to pull data via https. I grab the source, parse into data tables, save it to a database. That part is done, the issue is with the connection.
I am a Government Contractor, so my access level to the Proxy server is very limited. There is no authentication but they block everything but IE 7.0. For a http request, when I specify my IE userAgent it works great. But as soon as I make a https request,
the userAgent is hidden from the proxy server and it blocks my request. I have tried to use fiddler to watch my traffic and it is hidden there too, but I can see it when I change the code to an http address.
Is there anything I can do to make the UserAgent visible to the proxy for https connections?
See my example code if you would like to see the behavior.
private static string GetWebRequestContent(Uri uri)
string sid = String.Empty;
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri);
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)";
req.KeepAlive = false;
req.Proxy = new WebProxy("xxx.x.xx.xxxx", 8080);
using (HttpWebResponse res = (HttpWebResponse)req.GetResponse())
using (StreamReader sr = new StreamReader(res.GetResponseStream()))
sid = sr.ReadToEnd().Trim();
catch (WebException e)
Nov 05, 2009 05:48 PM|thuhue|LINK
Have you already tried the following?
Nov 06, 2009 07:45 AM|govdev|LINK
It seems to have more to do with .Net's httpwebrequest object and the way it handles secured connections. If I use IE and fiddler it can see the user agent when going to a HTTPS site, but hit the same site using httpwebrequest and all header data is blank.
If I do the same test with http site, I can mirror the browser/code.
Is it possible to rewrite the httpwebrequest module not to hide the header data from ssl requests? or use a 3rd party object class?