|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
C# windows applicationI 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_deepak***@hotmail.com kr_deepak***@yahoo.co.in kr_deepak***@skype.com Hi Deepak,
> // Create a new Uri object. The Uri argument in the WebProxy constructor specifies the url to the proxy > 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); 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. -- Show quoteDave Sexton "deepak" <dee***@discussions.microsoft.com> wrote in message news:FEE219EB-5336-4F97-8E60-0A7753D5B8DB@microsoft.com... > 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_deepak***@hotmail.com > > kr_deepak***@yahoo.co.in > > kr_deepak***@skype.com > > > > > |
|||||||||||||||||||||||