Access remoting object begin authenticating proxy

  • Thread starter Thread starter Scott Simms
  • Start date Start date
S

Scott Simms

I am accessing a remote object via HTTP binary remoting.
When using a non-authenticating proxy I set
the 'ProxyName' and 'ProxyPort' properties of the
HTTPChannel. When I use an authenticating proxy I get
a 'Proxy Authentication Required' error.

How do I setup remoting to pass proxy credentials? Can I
somehow use the WebProxy class?

Thanks,

Scott Simms.
 
Hello Scott,

Thanks for your post. Based on my experience and research, .NET Remoting
does not support proxy server authentication in version 1.0 or 1.1. That's
the reason why you will receive the error "Proxy Authentication Required".
Now I'd like to share the following information with you:

1. An easy workaround to this is to disable the proxy settings in IE. You
could also use the TCPChannel instead of the HttpChannel.

2. Another temporarily workaround is to use WebProxy as shown below. Please
kindly note that this workaround is not guaranteed to be successful in
future service packs because of changes in the code and functionality.

//--------------code snippet---------------------
HttpChannel channel = new HttpChannel();
ChannelServices.RegisterChannel(channel);
FieldInfo clientChannelField =
typeof(HttpChannel).GetField("_clientChannel",
BindingFlags.Instance | BindingFlags.NonPublic);
HttpClientChannel clientChannel = (HttpClientChannel)
clientChannelField.GetValue(channel);
FieldInfo clientChannelProxy =
typeof(HttpClientChannel).GetField("_proxyObject",
BindingFlags.Instance | BindingFlags.NonPublic);
IWebProxy proxy = new WebProxy("proxy",80);
// you can add credentials to the web proxy here...
clientChannelProxy.SetValue(clientChannel,proxy);
//-------------end of---------------------

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top