locked
DataServiceContext and proxy Servers RRS feed

  • Question

  • Is it possible to have the service context pick up the default proxy server settings when making a call?  I know that the following works but then I need to store the address and credentials as well.  Would be nice to piggyback the IE settings:


            void OnSendingRequest(object sender, SendingRequestEventArgs e)
            {
                // proxy server handling
                ICredentials credentials = new System.Net.NetworkCredential("username", "password", "domain");
                e.Request.Proxy = new System.Net.WebProxy("http://proxy:8888", true, null, credentials);

    Thursday, February 11, 2010 9:06 PM

Answers

  • Hi,

    If you're talking about the desktop .NET client (not Silverlight) then we use HttpWebRequest (that's what the e.Request is). In which case the normal .NET proxy rules apply. This is from the MSDN docs for the HttpWebRequest.Proxy property (http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.proxy.aspx) :
    The local computer or application config file may specify that a default proxy be used. If the Proxy property is specified, then the proxy settings from the Proxy property override the local computer or application config file and the HttpWebRequest instance will use the proxy settings specified. If no proxy is specified in a config file and the Proxy property is unspecified, the HttpWebRequest class uses the proxy settings inherited from Internet Explorer on the local computer. If there are no proxy settings in Internet Explorer, the request is sent directly to the server.

    So it seems that it should work out of the box. (I didn't try it though).

    Thanks,
    Vitek Karas [MSFT]
    Friday, February 12, 2010 10:27 AM
    Moderator

All replies

  • Hi,

    If you're talking about the desktop .NET client (not Silverlight) then we use HttpWebRequest (that's what the e.Request is). In which case the normal .NET proxy rules apply. This is from the MSDN docs for the HttpWebRequest.Proxy property (http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.proxy.aspx) :
    The local computer or application config file may specify that a default proxy be used. If the Proxy property is specified, then the proxy settings from the Proxy property override the local computer or application config file and the HttpWebRequest instance will use the proxy settings specified. If no proxy is specified in a config file and the Proxy property is unspecified, the HttpWebRequest class uses the proxy settings inherited from Internet Explorer on the local computer. If there are no proxy settings in Internet Explorer, the request is sent directly to the server.

    So it seems that it should work out of the box. (I didn't try it though).

    Thanks,
    Vitek Karas [MSFT]
    Friday, February 12, 2010 10:27 AM
    Moderator
  • Thanks for the response, I'll need to set up a test environment to be able to test this so I'll let you know how I get on.
    Wednesday, February 17, 2010 7:05 PM
  • Hi Jif,

     

    Would you mind letting us know how is the problem at your side?    

     

    Have a nice weekend!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, February 26, 2010 1:37 AM
    Moderator
  • I've had a few other issues to sort out before I can get to installing a proxy server and test this.  It happens at a client site and I don't have a proxy available at the moment.
    Friday, February 26, 2010 8:47 AM
  • The proxy is picked up from the IE setting so all is well.

    My problem is the authentication on the front of it uses ClientFormsAuthenticationMembershipProvider and I think that does not know what a proxy server is.
    Monday, March 8, 2010 2:45 AM
  • For those interested, the ADO.Net MembershipProvider uses the same mechanism and also picks up the default proxy settings.
    Monday, March 8, 2010 3:24 AM