Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
Anyway, I bit the bullet and went through and cleaned most of this up. The vast majority of these where related to ADO.NET parameters and ASP.NET Page Script objects, which have all moved to a separate Scripting object. Most of the stuff is just using a different method or possibly a different subobject - pure manual labor.
The last one I’m left with though is one I don’t know how to replace.
Warning 1 'System.Net.WebProxy.GetDefaultProxy()' is obsolete: 'This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202' D:\projects2005\wwIPStuff\wwHTTP.cs 500 31 wwIPStuff
I use GetDefaultProxy in my wwHttp component to automatically use Internet Explorer settings by default. One of the reasons I need to do this is so I can debug my HTTP requests with Fiddler which works through the IE settings.
I think from the reading that I’ve done on this, that .NET 2.0 now uses this setting by default now, so it’s probably no longer necessary to use this method, but I wonder then how you’d turn this behavior off.
Anybody know what the recommended replacement procedure is?
As a side note I’ve noticed that there is a problem with Whidbey and Proxy behavior. Under ASP.NET 2.0 doing XmlDocument.Load() or opening an Http Connection with HttpWebRequest, the connection seems to hang for about 10 seconds before starting to retrieve data on the first data retrieval.
This only happens under ASP.NET operation (or some other non-UI desktop account) – in a Console test of the same identical code runs fine without hesitation.
You can find out more about this here – I posted this as a bug on the feedback center:
Incidentally I have to say that MSDN Feedback center is a royal pain in the ass to use. It’s next to impossible to determine when an how a bug was updated and whether I need to respond to a bug or not. I see changes but often it’s just a status change without any action required. At one time I had 10 open issues and trying to keep up with it, I ended up missing a few valuable messages and feedback.
The process of submitting also is too tedious. I really gotta wonder WTF there isn’t a Web Service built straight into Visual Studio to do this. This would save a significant amount of re-typing all the information that the system can pick up automatically for me like the version number, language etc. When I fill out a bug I want to just fill out the error info and not take 5 minutes just to get to the point of actually filling a bug report.
Other Posts you might also like
- Adding minimal OWIN Identity Authentication to an Existing ASP.NET MVC Application
- Getting the Client IP Address in ASP.NET Core
- Resolving Paths To Server Relative Paths in .NET Code
- Map Physical Paths with an HttpContext.MapPath() Extension Method in ASP.NET
- Creating a custom HttpInterceptor to handle 'withCredentials' in Angular 6+
The Voices of Reason
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
http://msdn.microsoft.com/msdnmag/issues/05/08/AutomaticProxyDetection/default.aspx
The solution to the problem is to explicitly disable default proxy support in web.config, which essentially forces a direct connection:
<system.net>
<defaultProxy>
<proxy usesystemdefault="False"/>
</defaultProxy>
</system.net>
Voila HTTP access is fast again.
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
WebRequest.Proxy = HttpWebRequest.DefaultWebProxy;
This still begs the question on how to turn off proxy detection since auto-proxy now appears to be the default. Assigning null to the proxy? Declaratively I suspect we can use the same defaultproxy settings in the .config file to turn this off.
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
I think I have same problem,
I copied my ws to another machine in my intranet, with the release of .net 2.0.
now when after deploying my client (winform which connects to ws), I get the following error:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
Now , I wanted to know why my dev computers are fine , when others are throwing this exception? should I modify the machine.config or the app.config , is it client-or-server side problem??
Please give me the new config explicitly!
Thanks in advance,
Ilan :)
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
The environment i put my code does not have any proxy settings in the IE, and i dint get any proxy error while adding a webreferance there
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
I have the same problem with Breezback.
I tried to call a webservice from a desktop application and it returned that error.
Anybody knows how to solve this problem?
Thanks in advance..
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
IWebProxy aProxy = WebRequest.DefaultProxy;
is pretty good and it solved the block.
my question is how about on WINCE, as WebRequest.DefaultProxy is not supported by .net compact framework...
thanks
rick
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true" >
<proxy autoDetect="True" scriptLocation="http://wpad.premiers.qld.gov.au/wpad.dat"/>
</defaultProxy>
</system.net>
The above does exactly what IE does.
Im sure you can configure the default to what ever you require.
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
I have been through ways of failure for this, finally got right one.
1. refresh web service, enter the link like : http://testgsrs/Safety_Incident.asmx
2. In Reference.cs, change following clause to the new one:
this.Url = global::FA.Properties.Settings.Default.FA_testgsrs_Safety_Incident;
it fixed.
I have tried following ways in the assumption that proxy setting is the main reason. but not.
Nick. H. W.
//web.config
<!--
<system.net>
<defaultProxy>
<proxy usesystemdefault="False"/>
</defaultProxy>
</system.net>
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true" >
<proxy autoDetect="True" scriptLocation="http://ccm.ga.local/proxy.pac"/>
</defaultProxy>
</system.net>
-->
// in .cs
//System.Net.WebRequest.DefaultWebProxy = System.Net.HttpWebRequest.DefaultWebProxy; //Proxy,
//System.Net.IWebProxy aProxy = System.Net.WebRequest.DefaultWebProxy; // FASafetyConnection, DefaultProxy
//System.Net.WebRequest.DefaultWebProxy = null;
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
I don't understand the posts above. What should I do to this line of code:
this.WebRequest.Proxy = WebProxy.GetDefaultProxy();
Visual Studio doesn't like:
this.WebRequest.Proxy = WebRequest.DefaultProxy;
Please explain in simple terms.
Cheers
Paul
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
this.WebRequest.Proxy = WebRequest.DefaultWebProxy;
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
WebRequest.Proxy = HttpWebRequest.DefaultWebProxy
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
Your solution worked.
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
http://www.west-wind.com/weblog/posts/2005/Jul/11/Replacing-deprecated-SystemNetWebProxyGetDefaultProxy-in-NET-20#122350
# re: Replacing deprecated System.Net.WebProxy.GetDefaultProxy() in .NET 2.0?
IWebProxy aProxy = WebRequest.DefaultProxy;
and you are done.
Blair