I'm using the following function to try to determine how long it takes for a file to download from a webserver.
private void btnDownload_Click(object sender, System.EventArgs e)
{
//****************************************************
Uri uri = new Uri(" http://www.hide-link.com/ #search=%22unix%20filetype%3Apdf%22");
System.Net.WebRequest wr = System.Net.HttpWebRequest.Create(uri);
System.IO.Stream stream = wr.GetResponse().GetResponseStream();
int b;
int counter=0;
string strResult = string.Empty;
DateTime BeforeDlTime = DateTime.Now;
while ((b=stream.ReadByte())!=-1)
{
strResult += System.Text.UTF7Encoding.UTF7.GetString(new byte[] {
(byte)b },0,1);
counter++;
Response.Write(counter);
}
DateTime AfterDlTime = DateTime.Now;
stream.Close();
//****************************************************
}
However I'm getting the following error: Googling at the moment but not sure how to fix it...
Error
The underlying connection was closed: The remote name could not be resolved. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The underlying connection was closed: The remote name could not be resolved.
Source Error:
Line 55: Uri uri = new Uri(" http://www.hide-link.com/ #search=%22unix%20filetype%3Apdf%22"); Line 56: System.Net.WebRequest wr = System.Net.HttpWebRequest.Create(uri); Line 57: System.IO.Stream stream = wr.GetResponse().GetResponseStream(); Line 58: int b; Line 59: int counter=0;
Source File: c:\inetpub\wwwroot\downloadtime\webform1.aspx.cs Line: 57
Stack Trace:
[WebException: The underlying connection was closed: The remote name could not be resolved.] System.Net.HttpWebRequest.CheckFinalStatus() System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) System.Net.HttpWebRequest.GetResponse() DownLoadTime.WebForm1.btnDownload_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\downloadtime\webform1.aspx.cs:57 System.Web.UI.WebControls.Button.OnClick(EventArgs e) System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
Been googling for a while and can't find anything to help me fix this. This is an issue with my aspx webform and not a web service !
.NET Development27
|