Hi,
i tried with this code and it comiled and wokred fine but client
told me that when he traced the URL with his customized tool , he found that
my application is not using Proxy Script which i put in the texbox on the
form and i also found later that even code is working fine and application is
fine but we can not use URi class for Proxy Configuration Script.This is
wrong.This is nothing but we are using Address of URL which is diffrent from
ProxyScript.So this is not the solution.
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 proxyscript.
if anybody have idea ,Please advice (for yours refrence i m giving u the
code which i put ,this code is filling my 2 requirments(URL alone,URL with
address and port) out of total3(URL alone,URL with address and port ,URL with
proxyscript 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, I NEED CODE FOR THIS SECTION
// 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);
}
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks,
Deepak
"Vadym Stetsyak" wrote:
> Hello, deepak!
>
> Here's the sample that uses Proxy server
> ( http://www.c-sharpcorner.com/Code/20...dUsingHTTP.asp )
> ( http://www.codeproject.com/cs/intern...t_response.asp )
> d> Hi All,
> d> i m develpoing a .net Window application which has
> d> 4 texboxes(tbxURLmfor URL in URL Frame,tbxAddress for address in
> d> Proxy
> d> server frame,tbxPort for port in proxy server frame,tbxProxyScript
> d> for proxy
> d> script in proxy script frame) and a test button..The requirment is
> d> given below
>
> d> STEP BY STEP GUIDE
> d> 1. Input the URL you want to test
> d> 2. Choose Proxy script/Proxy server with Address and Port
> d> Information/No proxy
> d> 3. Enter url to proxy script or info for proxy server in respective
> d> text box
> d> 4. Press test-button
>
> d> ---------------My Code is
> d> -------------------------------------------------
> d> DateTime dt1 = DateTime.Now;
> d> System.Net.HttpWebRequest myReq =
> d> (HttpWebRequest)WebRequest.Create(tbxURL.Text.ToString());
> d> //GetResponse for this request.
> d> HttpWebResponse response = (HttpWebResponse)myReq.GetResponse();
> d> DateTime dt2 = DateTime.Now;
> d> lblTimeTaken.Text = Convert.ToString(dt2.Subtract(dt1));
> d> --------------------------------------------------------------------
> d> in this code , i m unable to set the value of proxy script textbox
> d> ,if any
> d> or proxy server(Address and port) ,only thing which i do threough
> d> this code
> d> is sending the url without any proxyscript ans proxy server(address
> d> and port
> d> info) Can anybody tell me how can i do this thorugh the code....
> d> ..
> d> i m working on window application as i need *.exe file rather than
> d> install
> d> file ....
>
>
> d> Thanks,
> d> Deepak
>
>
> --
> Regards, Vadym Stetsyak
> www: http://vadmyst.blogspot