Click here to Skip to main content
15,917,062 members
Home / Discussions / C#
   

C#

 
GeneralRe: A collection of instances that can be changed Pin
Heath Stewart23-Jun-04 7:22
protectorHeath Stewart23-Jun-04 7:22 
GeneralRe: A collection of instances that can be changed Pin
XanderSon23-Jun-04 15:22
XanderSon23-Jun-04 15:22 
GeneralINSERT Single-Quote Char into DB Tables Pin
Khang Nguyen22-Jun-04 12:53
Khang Nguyen22-Jun-04 12:53 
GeneralRe: INSERT Single-Quote Char into DB Tables Pin
Colin Angus Mackay22-Jun-04 12:57
Colin Angus Mackay22-Jun-04 12:57 
GeneralRe: INSERT Single-Quote Char into DB Tables Pin
Dave Kreskowiak22-Jun-04 13:03
mveDave Kreskowiak22-Jun-04 13:03 
GeneralRe: INSERT Single-Quote Char into DB Tables Pin
Werdna23-Jun-04 7:02
Werdna23-Jun-04 7:02 
GeneralRe: INSERT Single-Quote Char into DB Tables Pin
Heath Stewart13-Mar-05 16:29
protectorHeath Stewart13-Mar-05 16:29 
GeneralAutomatically authenticating with a Web proxy Pin
Arun Bhalla22-Jun-04 12:11
Arun Bhalla22-Jun-04 12:11 
I am developing an Internet Explorer bar, much like the Search sidebar. I need to make Web requests, and generally I use mshtml.HTMLDocument for that when I'm retrieving Web pages, but occasionally I need to make a lightweight connection to a Web service, and for that I use WebRequest.

The problem is that one of my clients uses an authenticating Web proxy. Apparently they need to login once with the username/password at the beginning of an Internet Explorer session, and from then on they are authenticated. When I'm using HTMLDocument, I don't have any trouble with the proxy as I suspect IE is using the same code. However, when I use WebRequest, I get proxy authentication errors, so I know that I have to authenticate with the proxy.

With some testing, I learned that
<code>
System.Net.WebProxy proxy = System.Net.WebProxy.GetDefaultProxy();
proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
System.Net.GlobalProxySelection.Select = proxy;
System.Net.WebRequest wr = System.Net.WebRequest.Create("http://www...");
</code>


does not work, but
<code>
System.Net.WebProxy proxy = System.Net.WebProxy.GetDefaultProxy();
proxy.Credentials = new System.Net.NetworkCredential(user, password);
System.Net.GlobalProxySelection.Select = proxy;
System.Net.WebRequest wr = System.Net.WebRequest.Create("http://www...");


does.

That is, .NET does not automatically detect the user/password pair which was inputted at the beginning of the IE session. The proxy settings seem to be static as GetDefaultProxy() returns the correct proxy address and port, but the credentials are empty. Furthermore, I don't know how I would be able to establish Web connections under the current proxy session within .NET. Since I expect a possible enterprise-wide deployment with this client, and possibly other enterprises, I would like to be able to use the proxy without having to request and maintain the user's proxy password (securely).

Does anyone know a way to go about this? If I have to poke around IE's registry settings to get this information, I'll happily do so, although it would be nicer to simply use .NET framework methods (e.g. GetDefaultProxy()). I've been poking around on this topic off and on for the past week or two, and I'm fairly stumped. It seems I may have to request the authentication information during the installation process, but that seems less than ideal.

Thanks!
Arun
GeneralRe: Automatically authenticating with a Web proxy Pin
Heath Stewart22-Jun-04 16:18
protectorHeath Stewart22-Jun-04 16:18 
GeneralRe: Automatically authenticating with a Web proxy Pin
Arun Bhalla1-Jul-04 7:44
Arun Bhalla1-Jul-04 7:44 
GeneralRe: Automatically authenticating with a Web proxy Pin
Heath Stewart1-Jul-04 17:03
protectorHeath Stewart1-Jul-04 17:03 
GeneralRe: Automatically authenticating with a Web proxy Pin
Arun Bhalla1-Jul-04 7:45
Arun Bhalla1-Jul-04 7:45 
GeneralFile Problem Pin
Peter Vertes22-Jun-04 9:29
Peter Vertes22-Jun-04 9:29 
GeneralRe: File Problem Pin
LongRange.Shooter22-Jun-04 9:50
LongRange.Shooter22-Jun-04 9:50 
GeneralRe: File Problem Pin
Peter Vertes22-Jun-04 10:15
Peter Vertes22-Jun-04 10:15 
GeneralRe: File Problem Pin
LongRange.Shooter22-Jun-04 10:32
LongRange.Shooter22-Jun-04 10:32 
GeneralRe: File Problem Pin
Peter Vertes22-Jun-04 11:17
Peter Vertes22-Jun-04 11:17 
GeneralRe: File Problem Pin
Heath Stewart22-Jun-04 11:43
protectorHeath Stewart22-Jun-04 11:43 
GeneralRe: File Problem Pin
Peter Vertes22-Jun-04 11:51
Peter Vertes22-Jun-04 11:51 
GeneralRe: File Problem Pin
Dave Kreskowiak22-Jun-04 13:07
mveDave Kreskowiak22-Jun-04 13:07 
GeneralRe: File Problem Pin
Peter Vertes23-Jun-04 8:49
Peter Vertes23-Jun-04 8:49 
GeneralUpdating text in a form while other tasks are happening Pin
quilkin22-Jun-04 9:25
quilkin22-Jun-04 9:25 
GeneralRe: Updating text in a form while other tasks are happening Pin
LongRange.Shooter22-Jun-04 9:42
LongRange.Shooter22-Jun-04 9:42 
GeneralRe: Updating text in a form while other tasks are happening Pin
quilkin23-Jun-04 8:12
quilkin23-Jun-04 8:12 
GeneralRe: Updating text in a form while other tasks are happening Pin
LongRange.Shooter23-Jun-04 8:49
LongRange.Shooter23-Jun-04 8:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.