Hi everyone, I'm getting the following error;
Error message:
System.Web.HttpException: The remote host closed the connection. The error code is 0x80072746.
at System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6.FlushCore(Byte[] status, Byte[] header, Int32 keepConnected, Int32 totalBodySize, Int32 numBodyFragments, IntPtr[] bodyFragments, Int32[] bodyFragmentLengths, Int32 doneWithSession, Int32 finalStatus, Boolean& async)
at System.Web.Hosting.ISAPIWorkerRequest.FlushCachedResponse(Boolean isFinal)
at System.Web.Hosting.ISAPIWorkerRequest.FlushResponse(Boolean finalFlush)
at System.Web.HttpResponse.Flush(Boolean finalFlush)
at System.Web.HttpResponse.Flush()
at downloadwindow.loadResourceInfo() in .CS PAGE:line 55
at ASP.ASPX PAGE__Render__control1(HtmlTextWriter __w, Control parameterContainer) in .ASPX PAGE:line 12
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
***************************************************************************
It only give's this error when the page is accessed while uploaded onto a certain server, it does not happen on our local server.
The code is;
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Net;
using System.IO;
public partial class downloadwindow : System.Web.UI.Page
{
// asp element declarations
public void loadResourceInfo()
{
////////////////////////////////
int downloads = 0;
string fileName;
////////////////////////////////
using (SqlConnection con = new SqlConnection()) // create new database connection
{
con.ConnectionString = (ConfigurationSettings.AppSettings["ConnectionString"]);
SqlParameter nrid = new SqlParameter("@nrid", SqlDbType.NVarChar);
nrid.Value = ID;
con.Open();
using (SqlCommand a = new SqlCommand("SELECT FilePath FROM tblDLR WHERE DLRID=@rid", con))
{
a.Parameters.Add(rid);
fileName = a.ExecuteScalar().ToString();
}
using (SqlCommand b = new SqlCommand("SELECT DH FROM tblDLR WHERE DLRID=@nrid", con))
{
b.Parameters.Add(nrid);
downloads = Convert.ToInt16(b.ExecuteScalar());
downloads++;
}
FileInfo fileInfo = new FileInfo(Server.MapPath("../" + fileName));
this.Response.Clear();
this.Response.AddHeader("Content-Length", fileInfo.Length.ToString());
this.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
this.Response.ContentType = "application/octet-stream";
this.Response.WriteFile(fileInfo.FullName);
this.Response.Flush();
this.Response.End();
}
}
}
Does anybody have any ideas or has at least had this error before, all help is most welcome.
Thanks!