473,387 Members | 1,318 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,387 software developers and data experts.

WebRequest over SSL and Proxy

I try to get a page from a https server. I can build up a connection
with WebRequest and everything runs fine without setting a proxy.

After setting a proxy, i get the error that i can't build a thrusted
connection to the remote server. If i try it over the IE i get a pop up
which tells me the same, but i can override it!

Anyone has i idea? i need that in combination with a cookiecontainer!

Code:

HttpWebRequest WReq = (HttpWebRequest)WebRequest.Create(url);
try
{
WebProxy myProxy = new WebProxy();
myProxy = (WebProxy)WReq.Proxy;
WReq.Proxy = myProxy;
}
catch { }
WReq.CookieContainer = new CookieContainer();
HttpWebResponse WResp = (HttpWebResponse)WReq.GetResponse();
CookieCollection WCookies = WResp.Cookies;
StreamReader sr = new StreamReader(WResp.GetResponseStream(),
Encoding.GetEncoding(1252));
while ((strTemp = sr.ReadLine()) != null)
{
strHTTPGet = strHTTPGet + strTemp + "\n";
}
for (int i=0; i<WResp.Cookies.Count; i++)
{
Cookie myCookie = new Cookie(WResp.Cookies[i].Name.ToString(),
WResp.Cookies[i].Value.ToString(), "/", ".<domain>");
myCookieContainer.Add(myCookie);
}

Thanks for your help!
Nov 15 '05 #1
1 6901
You have to obtain a certificate from the server via IE first. Check this
out:
http://www.microsoft.com/windows2000...roughs/default.
asp#section7

--
Horatiu Ripa

"Matthias Kwiedor" <cr********@hotmail.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
I try to get a page from a https server. I can build up a connection
with WebRequest and everything runs fine without setting a proxy.

After setting a proxy, i get the error that i can't build a thrusted
connection to the remote server. If i try it over the IE i get a pop up
which tells me the same, but i can override it!

Anyone has i idea? i need that in combination with a cookiecontainer!

Code:

HttpWebRequest WReq = (HttpWebRequest)WebRequest.Create(url);
try
{
WebProxy myProxy = new WebProxy();
myProxy = (WebProxy)WReq.Proxy;
WReq.Proxy = myProxy;
}
catch { }
WReq.CookieContainer = new CookieContainer();
HttpWebResponse WResp = (HttpWebResponse)WReq.GetResponse();
CookieCollection WCookies = WResp.Cookies;
StreamReader sr = new StreamReader(WResp.GetResponseStream(),
Encoding.GetEncoding(1252));
while ((strTemp = sr.ReadLine()) != null)
{
strHTTPGet = strHTTPGet + strTemp + "\n";
}
for (int i=0; i<WResp.Cookies.Count; i++)
{
Cookie myCookie = new Cookie(WResp.Cookies[i].Name.ToString(),
WResp.Cookies[i].Value.ToString(), "/", ".<domain>");
myCookieContainer.Add(myCookie);
}

Thanks for your help!

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pete Davis | last post by:
First of all, I apologize. I wanted to post this in microsoft.public.dotnet.framework (as it's a bit more appropriate there), but Outlook Express is suddenly giving me errors whenever I go to that...
1
by: Tim Regan | last post by:
Hi All, I'm writing an app using WebRequest in csharp. I need the app to respond to the host PC moving from one network to another, e.g. taking a laptop home after work. Currently the...
1
by: DWrek | last post by:
Hi Everyone, I have a .NET dll that uses the HTTPWebRequest class to make an HTTP connection to an off-site server. This dll works just fine from a Winform but when I try to use it from an ASP...
4
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server...
0
by: Frank S. | last post by:
Hello, when I try to execute a web request from a .NET client application through a proxy, the server returns a 401 (not authorized) error message. It works when i bypass the proxy or when i...
2
by: davidcbrown | last post by:
I started using .NET 2003 and my first application is to parse an HTML form. But I am behind an ISA firewall and get "(407) Proxy Authentication Required" with the following code. The proxy...
6
by: Jensen Bredhal | last post by:
Hello, I need to send command to a web server from a method. I understand this should be possible using the WebClient or WebRequest class. how can this be done? below an example of my...
5
by: james.dixon | last post by:
Hi I have been struggling with what should be a simple thing. I want to crawl the web for specific links, and save any html and files that meet my criteria to my hard drive. I thought that...
2
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.