473,790 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IWebProxy and the SystemProxy


Just have some general questions on how it's supposed to work. When i get
WebREquest.GetS ystemWebPRoxy it returns a
System.Net.WebR equest+WebProxy WrapperOpaque type. Which doesn't have any
public property to set useDefaultCrede ntials. I assign this to the ws proxy
and set the UseDefaultCrede ntials, 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.Get Proxy(uriToProb e);
if( uriToProbe != uriFromProxy ) {
// real proxy is set so i can get the port/address from the
UriFromProxy
WebProxy proxyObject = new WebProxy(addres sWithPort, true);
proxyObject.Use DefaultCredenti als = 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 11637
Hello cisco man,

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

For the "useDefaultCred entials" property of WebProxy class, it simply
assign the corresponding credentials to the IWebProxy.Crede ntials
property(accord ing to the given value). Here is the diassembed code from
reflector:

=====from WebProxy class======
public bool UseDefaultCrede ntials
{
get
{
if (!(this.Credent ials is SystemNetworkCr edential))
{
return false;
}
return true;
}
set
{
this._Credentia ls = value ? CredentialCache .DefaultCredent ials
: null;
}
}

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

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

=============== ========
IWebProxy proxy = WebRequest.GetS ystemWebProxy() ;

proxy.Credentia ls = System.Net.Cred entialCache.Def aultCredentials ;
=============== ========

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 UseDefaultCrede ntials. Once i set it to the
DefaultCredenti als 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
DefaultCredenti als 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.GetS ystemWebPRoxy it does return a
"System.Net.Web Request+WebProx yWrapperOpaque" type which is internal.
Actually, when using the returned object from WebRequest.GetS ystemWebProxy
method, you're always suggested to use the "IWebProxy" interface as that
interface has provide all the necessary properties.

For the "useDefaultCred entials" property of WebProxy class, it simply
assign the corresponding credentials to the IWebProxy.Crede ntials
property(accord ing to the given value). Here is the diassembed code from
reflector:

=====from WebProxy class======
public bool UseDefaultCrede ntials
{
get
{
if (!(this.Credent ials is SystemNetworkCr edential))
{
return false;
}
return true;
}
set
{
this._Credentia ls = value ? CredentialCache .DefaultCredent ials
: null;
}
}

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

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

=============== ========
IWebProxy proxy = WebRequest.GetS ystemWebProxy() ;

proxy.Credentia ls = System.Net.Cred entialCache.Def aultCredentials ;
=============== ========

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
980
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 without a hitch). Before I use this class, I make the necessary calls to instantiate a WebProxy class and then pass in my credentials to set the WebProxy.Credentials property so I can get through the proxy server.
6
2912
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 Settings\AutoConfigURL I have the adress of a script,
10
25139
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 through proxy. eg, _socket = new TcpClient("http://msdn.microsoft.com", port); does not work. Thanx. Ab.
3
2332
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 expose that class for ASP COM Interop. Any suggestion? Error dump ----------------------------------
6
4552
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 underlying connection was closed: Unable to connect to the remote server."
0
7282
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 aborted: The request was canceled" after about 7 MB. For example, I might be uploading a 73MB file. After about 11% done the upload aborts. :shake: It works great for files < 5MB. I can upload those every time.
3
9554
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 httpwebrequest.GetReponse() function call throws the above error. So here's what i do in the case it works.. //THIS WORKS
0
1597
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 need to accomplish is to have a seperate proxy for each instance of the webbrowser control. i have thread a simple version of the application. but that did not work i was wondering if i could set an instance of the IWebProxy to allow for the change...
3
2577
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 WebClient(); client.Credentials = netCredential; Console.WriteLine(client.DownloadString(RequestUrl)); However, when I run behind a proxy I get an exception that I need to
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10419
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10147
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9987
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6770
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.