为什么我在尝试显示PDF时收到此错误?

时间:2017-04-15 06:01:29

标签: c#

" 资源被解释为文档但使用MIME类型application / pdf传输"

这只发生在Chrome上。注意:我使用的是ITextSharp.PDF。 有任何想法吗?

这是我的标题:

 private void ShowPdf(string pdf_location, string community_name, DateTime date_issued, string type, string community_city, string community_state)
        {
            //Get base certificate pdf, add school name and date, and open the pdf on the user's computer
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/pdf";
            Response.AddHeader
            ("Content-Disposition", "inline; filename=certificate.pdf");

            if (type == "certified")
            {
                Response.BinaryWrite(CommunityWildlifeHabitat.Models.PDF_DesignerCertifed.ReturnPDFByteStream(pdf_location, community_name, date_issued));
            } 
            if (type == "registered")
            {
                Response.BinaryWrite(CommunityWildlifeHabitat.Models.PDF_DesignerRegistered.ReturnPDFByteStream(pdf_location, community_name, date_issued, community_city, community_state));
            }
            Response.End();
            Response.Flush();
            Response.Clear();
        }

0 个答案:

没有答案