Click here to Skip to main content
15,906,341 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
dear everyone i made a windows application that connect to web service and get data from it.

many of my customers uses proxy to block the internet for users

all that i need to know is how to add proxy authentication details in my application to let the application connect to web service??

i want to show a form to add proxy details like this link (print screen)
i am using this code but i am still getting error and i can not connect to wen service

C#
if (WebRequest.DefaultWebProxy.GetProxy(new System.Uri("https://www.o-survey.com/")).ToString() == "https://www.o-survey.com/")
            {
                MessageBox.Show("A proxy is not in use here");
            }
            else
            {
                MessageBox.Show("A proxy is in use here");
            }
 

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.o-survey.com");

            IWebProxy proxy = request.Proxy;
            if (proxy != null)
            {
                MessageBox.Show("Proxy: {0}"+ proxy.GetProxy(request.RequestUri));
            }
            else
            {
                MessageBox.Show("Proxy: {0}Proxy is null; no proxy will be used");
            }

            WebProxy myProxy = new WebProxy();
            Uri newUri = new Uri("http://192.168.1.240:6588");
            // Associate the newUri object to 'myProxy' object so that new myProxy settings can be set.
            myProxy.Address = newUri;
            // Create a NetworkCredential object and associate it with the 
            // Proxy property of request object.
            myProxy.Credentials = new NetworkCredential("john", "johngra");
            request.Proxy = myProxy;



please advice as soon as possible
Posted
Comments
Denis Shemenko 8-Jul-13 0:17am    
And...???
John_Tadros 8-Jul-13 3:56am    
i can not login to net through this code
Denis Shemenko 8-Jul-13 4:19am    
http://msdn.microsoft.com/en-us/library/system.net.webrequest.proxy.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900