none
PDF in ImageButton return an X, but jpg return picture fine RRS feed

  • Question

  • Hi, 

    My C# asp page has an ImageButton ImgB1 for previewing graphics and pdf from sql database Image data type.
    I'm using a Handler.ashx for showing the image.
    However, if Image data from sql is a jpg, the ImgB1 shows good picture;
    but if the data from sql is a pdf, the ImgB1 just presents an X sign.
    The code in my Handler.ashx:

    context.Response.Clear();
    context.Response.ContentType = "application/pdf";
    context.Response.AddHeader("content-length", goodBuffer.Length.ToString());
    context.Response.BinaryWrite(goodBuffer);
    context.Response.Flush();
    context.Response.Close();
    context.Response.End();

    How do I fix this problem?
    Thanks for help.

    Jason

    • Moved by CoolDadTx Thursday, May 2, 2019 6:23 PM ASP.NET related
    Thursday, May 2, 2019 8:41 AM

All replies

  • If you write the pdf to the computer hard disk can you open it?  What browser are you using for testing?
    Thursday, May 2, 2019 8:45 AM
  • Hi JasonHuang8888,

    Thank you for posting here.

    Since this thread is related to asp.net, you could post in the following forum.

    https://forums.asp.net/

    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Jack



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 2, 2019 8:57 AM