PC Review


Reply
Thread Tools Rate Thread

C# Windows Applications

 
 
=?Utf-8?B?ZGVlcGFr?=
Guest
Posts: n/a
 
      27th Nov 2006
Hi All,

I read article
(http://msdn.microsoft.com/msdnmag/is...n/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/ac...d_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

(E-Mail Removed)

(E-Mail Removed)

(E-Mail Removed)





 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=
Guest
Posts: n/a
 
      27th Nov 2006
The framework doesnt do this for you automatically. You need to either write
the code to change the system settings to use the script you want, or use the
code from the sidebar to host the script yourself and call the functions in
it to get the proxy settings.
If you dont want to affect the system then the side bar is the only way to
go. Download the code and work with that stuff.

Ciaran O'Donnell

"deepak" wrote:

> Hi All,
>
> I read article
> (http://msdn.microsoft.com/msdnmag/is...n/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/ac...d_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
>
> (E-Mail Removed)
>
> (E-Mail Removed)
>
> (E-Mail Removed)
>
>
>
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to port windows applications to compact framework applications? miloszl@gmx.de Microsoft Dot NET Compact Framework 4 15th Jun 2005 12:18 PM
The system file is not suitable for running MS-DOS and Microsoft Windows applications (on Windows 2000) Alex Vinokur Microsoft Windows 2000 1 21st Oct 2004 08:43 AM
Windows applications versus web applications =?Utf-8?B?QnJhZCBTaW1vbg==?= Microsoft Dot NET 3 12th Jul 2004 07:29 PM
What does Error message: 16 Bit Windows Subsystem: config.nt. The system file is not suitable for running MS_DOS and MS Windows applications? How can I correct this? =?Utf-8?B?cnN2cHJpY2hAc3lhaG9vLmNvbQ==?= Windows XP General 2 8th Feb 2004 12:37 PM
Problem moving applications from Windows XP Pro to Windows 2003 Server Michael Johnson Sr. Microsoft ASP .NET 0 4th Feb 2004 07:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:36 PM.