例外“远程主机关闭连接。错误代码为0x800703E3。”

时间:2011-02-15 06:58:30

标签: c# .net asp.net-mvc-2

    try
    {
        int _quarterId = 0;
        if (id != null)
        {
            _quarterId = (int)id;
        }
        else
        {
            _quarterId = Utility.GetQuarterIdFromSession();
        }

        int _businessId = Utility.GetBusinessIdFromSession();

        if (_quarterId > 0 && _businessId > 0)
        {
            Return _return = _engineService.GetFormPdf(_quarterId, _businessId);
            if (_return != null && _return.FormPDF != null &&
                _return.FormPDF.Length > 0)
            {
                Response.Clear();
                Response.Buffer = false;
                Response.AddHeader("Accept-Header", _return.FormPDF.Length.ToString());
                Response.ContentType = "application/pdf";
                Response.AddHeader("Content-Disposition", "attachment; filename= FormPdf.pdf");
                Response.AddHeader("content-length", _return.FormPDF.Length.ToString());
                Response.BinaryWrite(_return.FormPDF);
                Response.Flush();
            }
        }
    }
    catch (ThreadAbortException)
    {

    }
    //This sets empty content and avoids the exception in changing the HTTP header
    return new EmptyResult();
}

0 个答案:

没有答案