Response.ContentType = "Application/pdf"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bjorn Sagbakken

    Response.ContentType = "Application/pdf"

    With ASP.NET 2.0
    I'm trying to display the pdf file directly in the client browser, but I
    only get a download dialogue box. Downloading the file works fine, but I
    want to view the PDF directly.

    I get the same response with:

    Response.Conten tType="Applicat ion/X-unknown" which is more understandable.

    The Response.Conten tType="Applicat ion/pdf" doesn't seem to tell the browser
    that this actually is a PDF-file.

    Mybe there is only a mistyping, but I shuld like a complete list of the
    options for ContentType, like what phrase to use for all kind of files.
    Anyone that knows where to find this?

    (I have searched through help without finding a listing of all the filetypes
    available)

    Bjorn


  • Mark Fitzpatrick

    #2
    Re: Response.Conten tType = "Applicati on/pdf"

    Bjorn,
    You won't find a listing of possible contenttypes because there is
    no set list. The content type just sets the MIME type for an element. MIME
    types are constantly being expanded upon as new file formats are being
    developed.

    You can google for them. There's a table with a number of major MIME
    types at:


    Application/pdf should work. The Application/X-unknown is the one
    that developers use to force the browser to download the file. It could also
    be an issue where your browser is not associating the pdf file with the
    viewer correctly.
    --
    Hope this helps,
    Mark Fitzpatrick
    Former Microsoft FrontPage MVP 199?-2006


    "Bjorn Sagbakken" <bjo-sag@online.nowr ote in message
    news:xYidnXKxw-4NO8HbRVnzvAA@t elenor.com...
    With ASP.NET 2.0
    I'm trying to display the pdf file directly in the client browser, but I
    only get a download dialogue box. Downloading the file works fine, but I
    want to view the PDF directly.
    >
    I get the same response with:
    >
    Response.Conten tType="Applicat ion/X-unknown" which is more understandable.
    >
    The Response.Conten tType="Applicat ion/pdf" doesn't seem to tell the
    browser that this actually is a PDF-file.
    >
    Mybe there is only a mistyping, but I shuld like a complete list of the
    options for ContentType, like what phrase to use for all kind of files.
    Anyone that knows where to find this?
    >
    (I have searched through help without finding a listing of all the
    filetypes available)
    >
    Bjorn
    >

    Comment

    • Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

      #3
      Re: Response.Conten tType = &quot;Applicati on/pdf&quot;

      Try adding this line:
      Response.AddHea der("Content-Disposition", "inline;filenam e="Filename.pdf ");

      --
      I hope this helps,
      Steve C. Orr,
      MCSD, MVP, CSM, ASPInsider



      "Bjorn Sagbakken" <bjo-sag@online.nowr ote in message
      news:xYidnXKxw-4NO8HbRVnzvAA@t elenor.com...
      With ASP.NET 2.0
      I'm trying to display the pdf file directly in the client browser, but I
      only get a download dialogue box. Downloading the file works fine, but I
      want to view the PDF directly.
      >
      I get the same response with:
      >
      Response.Conten tType="Applicat ion/X-unknown" which is more understandable.
      >
      The Response.Conten tType="Applicat ion/pdf" doesn't seem to tell the
      browser that this actually is a PDF-file.
      >
      Mybe there is only a mistyping, but I shuld like a complete list of the
      options for ContentType, like what phrase to use for all kind of files.
      Anyone that knows where to find this?
      >
      (I have searched through help without finding a listing of all the
      filetypes available)
      >
      Bjorn
      >

      Comment

      • Bjorn Sagbakken

        #4
        Re: Response.Conten tType = &quot;Applicati on/pdf&quot;

        Response.AddHea der("Content-Disposition", "inline;filenam e="Filename.pdf ")
        This result in a blank screen. Right-clicking on the form to view source for
        curiosity show this message:
        "The XML source file is unavailable for viewing" --But I have not added
        anything XML-like to my form.
        Note, I retrieve the pdf from a SQL server, using
        "Response.Binar yWrite(FileByte )" as output.

        Response.AddHea der("Content-Disposition",
        "attachment;fil ename="Filename .pdf")
        This causes the download box to appear. Ok for the moment, but not as
        intended.

        I just don't know why this happens. Maybe something in the @ page area or in
        the html-header of the file?
        Or in the settings of the browser?

        Bjorn

        "Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <Steve@Orr.netw rote in
        message news:BFA4B09F-E1BA-45DF-A8D3-872CD60A165D@mi crosoft.com...
        Try adding this line:
        Response.AddHea der("Content-Disposition",
        "inline;filenam e="Filename.pdf ");
        >
        --
        I hope this helps,
        Steve C. Orr,
        MCSD, MVP, CSM, ASPInsider

        >
        >
        "Bjorn Sagbakken" <bjo-sag@online.nowr ote in message
        news:xYidnXKxw-4NO8HbRVnzvAA@t elenor.com...
        >With ASP.NET 2.0
        >I'm trying to display the pdf file directly in the client browser, but I
        >only get a download dialogue box. Downloading the file works fine, but I
        >want to view the PDF directly.
        >>
        >I get the same response with:
        >>
        >Response.Conte ntType="Applica tion/X-unknown" which is more
        >understandable .
        >>
        >The Response.Conten tType="Applicat ion/pdf" doesn't seem to tell the
        >browser that this actually is a PDF-file.
        >>
        >Mybe there is only a mistyping, but I shuld like a complete list of the
        >options for ContentType, like what phrase to use for all kind of files.
        >Anyone that knows where to find this?
        >>
        >(I have searched through help without finding a listing of all the
        >filetypes available)
        >>
        >Bjorn
        >>
        >

        Comment

        • Bjorn Sagbakken

          #5
          Re: Response.Conten tType = &quot;Applicati on/pdf&quot;

          Thanks,

          Your link was just what I was looking for.

          Bjorn
          "Mark Fitzpatrick" <markfitz@fitzm e.comwrote in message
          news:uUixwLkoHH A.4400@TK2MSFTN GP03.phx.gbl...
          Bjorn,
          You won't find a listing of possible contenttypes because there is
          no set list. The content type just sets the MIME type for an element. MIME
          types are constantly being expanded upon as new file formats are being
          developed.
          >
          You can google for them. There's a table with a number of major
          MIME types at:

          >
          Application/pdf should work. The Application/X-unknown is the one
          that developers use to force the browser to download the file. It could
          also be an issue where your browser is not associating the pdf file with
          the viewer correctly.
          --
          Hope this helps,
          Mark Fitzpatrick
          Former Microsoft FrontPage MVP 199?-2006
          >
          >
          "Bjorn Sagbakken" <bjo-sag@online.nowr ote in message
          news:xYidnXKxw-4NO8HbRVnzvAA@t elenor.com...
          >With ASP.NET 2.0
          >I'm trying to display the pdf file directly in the client browser, but I
          >only get a download dialogue box. Downloading the file works fine, but I
          >want to view the PDF directly.
          >>
          >I get the same response with:
          >>
          >Response.Conte ntType="Applica tion/X-unknown" which is more
          >understandable .
          >>
          >The Response.Conten tType="Applicat ion/pdf" doesn't seem to tell the
          >browser that this actually is a PDF-file.
          >>
          >Mybe there is only a mistyping, but I shuld like a complete list of the
          >options for ContentType, like what phrase to use for all kind of files.
          >Anyone that knows where to find this?
          >>
          >(I have searched through help without finding a listing of all the
          >filetypes available)
          >>
          >Bjorn
          >>
          >
          >

          Comment

          Working...