I am trying to stop this warning in IIS and I am reading that I should check this object IsClientConnected before I call TransmitFile(filename) . Is this correct or is Another way to correct this ?
IIS exception
Exception information: Exception type: HttpException Exception message: The remote host closed the connection. The error code is 0x800703E3. at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean ?throwOnDisconnect)
if (context.Response.IsClientConnected)
{
context.Response.Clear();
context.Response.ClearContent();
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.AddHeader("Expires", "-1");
context.Response.ContentType = "application/pdf";
context.Response.TransmitFile(filename);
context.Response.Flush();
context.Response.End();
}
else
{
context.Response.End();
}
updated Code
try
{
context.Response.Clear();
context.Response.ClearContent();
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.AddHeader("Expires", "-1");
context.Response.ContentType = "application/pdf";
context.Response.TransmitFile(filename);
context.ApplicationInstance.CompleteRequest()
//context.Response.Flush();
//context.Response.End();
}
catch (HttpException hex)
{
}
FlushandEnd. let the server handle that for you.catchthe exception.FlushandEndthe problem? what aboutTransmitFile?`