Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / November 2006

Tip: Looking for answers? Try searching our database.

C# windows application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
deepak - 27 Nov 2006 08:04 GMT
Hi All,

I read article
(http://msdn.microsoft.com/msdnmag/issues/05/08/AutomaticProxyDetection/default.aspx). I need yours help. Please advise me  

My Requirement is given below.



  This is C# windows .net application(application as i need *.exe file
rather than install file ) which has 4 textboxes (tbxURL for URL in URL
Frame, tbxAddress for address in Proxy server frame, tbxPort for port in
proxy server frame, tbxProxyScript for proxy script in proxy script frame)
and a test button. The requirement is given below

STEP BY STEP GUIDE
1. Input the URL you want to test
2. Choose Proxy script/Proxy server with Address and Port Information/No proxy
3. Enter url to proxy script or info for proxy server in respective text box.
4. Press test-button


e.g.

A) Proxy Script (Textbox):
http://www-proxy.ericsson.se:3132/accelerated_pac_base.pac
B) URL (Textbox): any URL which starts from https://
C) Proxy Server (2 text box one for Address and one for Port):e.g.
10.187.1.20 and 8080

The below code is working fine for url (only URL, No Proxy Server i.e.
Address and Port, no Proxy Script), URL with Proxy Server (Address, Port) as
given in coding but not for URL AND Proxy Script, That code needs to be
changed.


so my question is how to do coding for calling URL when you want to access
that URL(mentioned in the textbox on the window form) with proxy
script.(which is filled in the textbox present on the window form. Please
advice (for yours reference, I am giving you the code which I put, this code
is filling my 2 requirements (URL alone), URL with address and port) out of
total3 (URL alone, URL with address and port, URL with proxy script only)

ß-----------------------------------------------------------------------------My
Code is given
below-------------------------------------------------------------------------------------------------------------------------------à
private void Calc_Time_For_URL()

           {                                  

                 if(tbxURL.Text.StartsWith("https://"))

                 {

                       //Time of Request

                       DateTime dt1 = DateTime.Now;        



                       try

                       {                                                    
                                   

                             System.Net.HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create(tbxURL.Text.ToString());                    



                             //Proxy Server(Address and Port)

                             if ((tbxAddress.Text.Length > 0) &
(tbxPort.Text.Length >0))

                             {

                                   myReq.Proxy = new
WebProxy(tbxAddress.Text,Convert.ToInt16(tbxPort.Text));                      
                                   

                             }                                  



                             //Proxy Script

                             if (tbxProxyScript.Text.Length > 0)

                             {          



                             ß--------------THIS CODE IS WRONG AND NOT
WORKING AND NEEDS TO BE CHANGED                                              
                         

                                   // Create a new Uri object.

                                   Uri newUri=new Uri(tbxProxyScript.Text);



                                   // Associate the newUri object to
'myProxy' object so that new myProxy settings can be set.

                                   myReq.Proxy = new WebProxy(newUri);

                             
-------------------------------------------------à

                                         

                             }

                         

                             //GetResponse for this request.                
     

                             HttpWebResponse response =
(HttpWebResponse)myReq.GetResponse();



                             //Time of Response  

                             DateTime dt2 = DateTime.Now;                    

                             lblTimeTaken.Text =
Convert.ToString(dt2.Subtract(dt1));

                             //}                                            
                                   



                       }



                       catch(System.Exception ex)

                       {    

                             //Time of Response  

                             DateTime dt3 = DateTime.Now;                    

                             lblTimeTaken.Text =
Convert.ToString(dt3.Subtract(dt1));



                             string message = "Make Sure URL is enterted
with http://www or https://www as prefix as per your

need!!!\nError returned is :\n " + ex.Message;

                             string caption = "Error!!!";

                             DialogResult result;

                             MessageBoxButtons buttons =
MessageBoxButtons.OK;

                             result =
MessageBox.Show(message,caption,buttons);

                       }



My Doubt is should we have to call any API..?Actually there is one exe file
named “proxycfg.exe" inside C:\windows\system32



Thanks,

Deepak

+919886735837

kr_deepak123@hotmail.com

kr_deepak123@yahoo.co.in

kr_deepak123@skype.com
Dave Sexton - 27 Nov 2006 18:33 GMT
Hi Deepak,

>                                    // Create a new Uri object.
>                                    Uri newUri=new
[quoted text clipped - 4 lines]
>
>                                    myReq.Proxy = new WebProxy(newUri);

The Uri argument in the WebProxy constructor specifies the url to the proxy
server, not a proxy script.

The article to which you linked us indicates that you must make registry
changes to configure proxy script discovery, which can be done through IE.
It states that the 2.0 framework reads all of the proxy script registry
settings (implying that 1.* doesn't, but I didn't read the section on 1.1
within the article to find out).

If you want to try making the registry changes in code, you can use the
Microsoft.Win32.Registry class.

Signature

Dave Sexton

> Hi All,
>
[quoted text clipped - 157 lines]
>
> kr_deepak123@skype.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.