473,406 Members | 2,220 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,406 software developers and data experts.

IWebProxy and the SystemProxy


Just have some general questions on how it's supposed to work. When i get
WebREquest.GetSystemWebPRoxy it returns a
System.Net.WebRequest+WebProxyWrapperOpaque type. Which doesn't have any
public property to set useDefaultCredentials. I assign this to the ws proxy
and set the UseDefaultCredentials, on the proxy object, to true. This
doesn't seem to work when dealing with a proxy that is using ISA server and
validating credentials with the domain. Is this the proper way of doing this?
Why do i need to create a WebProxy object if the SystemProxy being returned
has it all. It just seems like if i could set that property on the proxy
object itself, it would work

So i end up doing something like [1] as well as have the user type it in
if he/she wants to.
Uri uriFromProxy = systemProxy.GetProxy(uriToProbe);
if( uriToProbe != uriFromProxy ) {
// real proxy is set so i can get the port/address from the
UriFromProxy
WebProxy proxyObject = new WebProxy(addressWithPort, true);
proxyObject.UseDefaultCredentials = true;
}

I guess what i'm asking is what is the proper way of handling proxy
server's, in general, with web services? MS seems to release a lot of
general practices but i think i missed this one.

Thanks!
Feb 15 '07 #1
3 11601
Hello cisco man,

As for the WebRequest.GetSystemWebPRoxy it does return a
"System.Net.WebRequest+WebProxyWrapperOpaque" type which is internal.
Actually, when using the returned object from WebRequest.GetSystemWebProxy
method, you're always suggested to use the "IWebProxy" interface as that
interface has provide all the necessary properties.

For the "useDefaultCredentials" property of WebProxy class, it simply
assign the corresponding credentials to the IWebProxy.Credentials
property(according to the given value). Here is the diassembed code from
reflector:

=====from WebProxy class======
public bool UseDefaultCredentials
{
get
{
if (!(this.Credentials is SystemNetworkCredential))
{
return false;
}
return true;
}
set
{
this._Credentials = value ? CredentialCache.DefaultCredentials
: null;
}
}

public ICredentials Credentials
{
get
{
return this._Credentials;
}
set
{
this._Credentials = value;
}
}
================

therefore, the setting "UseDefaultCredentials" of WebProxy to true is
identical to the following code (for IWebProxy):

=======================
IWebProxy proxy = WebRequest.GetSystemWebProxy();

proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
=======================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 16 '07 #2
Steven,

Thanks for the post. I did use reflector but didn't bother looking at the
implementation of UseDefaultCredentials. Once i set it to the
DefaultCredentials everything worked fine.

The only thing that bothers me is that i'm relying on that implementation
but i guess it makes sense that setting the ICredential property to the
DefaultCredentials would force it to this. Even if it didn't it will still
use the default creds anyway. Thanks again!
Thanks again,
Cisco

"Steven Cheng[MSFT]" wrote:
Hello cisco man,

As for the WebRequest.GetSystemWebPRoxy it does return a
"System.Net.WebRequest+WebProxyWrapperOpaque" type which is internal.
Actually, when using the returned object from WebRequest.GetSystemWebProxy
method, you're always suggested to use the "IWebProxy" interface as that
interface has provide all the necessary properties.

For the "useDefaultCredentials" property of WebProxy class, it simply
assign the corresponding credentials to the IWebProxy.Credentials
property(according to the given value). Here is the diassembed code from
reflector:

=====from WebProxy class======
public bool UseDefaultCredentials
{
get
{
if (!(this.Credentials is SystemNetworkCredential))
{
return false;
}
return true;
}
set
{
this._Credentials = value ? CredentialCache.DefaultCredentials
: null;
}
}

public ICredentials Credentials
{
get
{
return this._Credentials;
}
set
{
this._Credentials = value;
}
}
================

therefore, the setting "UseDefaultCredentials" of WebProxy to true is
identical to the following code (for IWebProxy):

=======================
IWebProxy proxy = WebRequest.GetSystemWebProxy();

proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
=======================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights
Feb 21 '07 #3
You're welcome :)

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Feb 21 '07 #4

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

Similar topics

5
by: Bill Hauver | last post by:
I am attempting to use a web service from my work pc which is behind a firewall. I have used wsdl.exe to create the web service reference class and added it to my project. (this seems to work...
6
by: Prehaut Anselme | last post by:
Hi, I have found the script of the .pac where to obtain the specification to obtain a proxy when we use IE This adress is in the HKCU\Softawre\Microsoft\Windows\CurrentVersion\Internet...
10
by: Abubakar | last post by:
hi, I work on a computer that is part of a network and uses proxy to connect to net. I cant connect to servers outside my proxy with simple ConnectTo code. I need to know how to make my requests go...
3
by: Pritam Bhat | last post by:
Hi, I recently upgraded my XML parser and the ComInterop code that I had for my webservice is throwing the following error. For ASP applications, we created a wrapper class on this web service and...
6
by: Daniel Santana | last post by:
Anyone knows how to add web reference in C#, when the internet need authentication. The credentials for proxy is asked and I pass the information. But after all, I got this message: "The...
0
by: Alex | last post by:
my app was working fine in VB.NET 2003 (and framework 1.1). Now with VB.NET 2005 (framework 2.0) the uploading to an http server (ie. www.sharebigfile.com) stops with the error "The request was...
3
by: nandan | last post by:
Yes. My client has a proxy server. That much i know. In my application I make two kinds of calls that are affected by the proxy server I finally got the webservice call working. But my...
0
by: scottietrek | last post by:
I have a webbrowser control that allows me to save username and password infromation for a proxy server and i have been successful in changing the system default proxy for my application. What i now...
3
by: =?Utf-8?B?SmFsaWw=?= | last post by:
My code below works fine when I am no using web proxy: //login and pwd is for the remote server. NetworkCredential netCredential = new NetworkCredential(login,pwd); WebClient client = new...
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
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...
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:
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...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.