How to map the .PDF file extension to the ASP.NET dll

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default How to map the .PDF file extension to the ASP.NET dll

    Should you be able to map a any file extension to the ASP.NET dll and
    have it execute ASP.NET script, just like an .aspx page, when it is
    requested by a browser. If not, why bother giving us the ability to
    create application mappings.

    I have an .aspx page that calls an SAP function which returns an
    actual PDF to my calling .aspx. My .aspx then returns that PDF result
    to the browser.

    When a browser requests that .aspx page, if I try to return that PDF
    result as a response back to the calling browser, the browser does not
    recognize it as a PDF (thus loading up Adobe Acrobat, etc.). This is
    even after I have set the content type to "application/pdf".

    The browser is smart enough to know that this isn't a typical HTML
    page, so it asks me if I want to Open or Save or Cancel this document.
    If I click Save, then it tries to save it as an .aspx document, which
    I understand, but I do not want to happen. I'd rather it at least try
    to save it as a PDF. If I click Open, then it quite naturally tries
    to open it as an .aspx page, which means it opens up the PDF results
    in Visual Studio, which is also not what I want.

    So I was trying to figure out how I can get a browser to request a
    file that can dynamically create a PDF using ASP.NET script AND have
    the browser know that the response is a PDF and thus, open it up in
    Adobe Acrobat.

    I am assuming at this point that the only way a an unknown user's
    browser can reliably open up a file within Adobe is if it has the
    actual PDF extension. I then decided to create a special web
    application where I would map the .PDF extension to the ASP.NET dll in
    my application mappings. Then, I would rename my webform1.aspx file
    to webform1.pdf. Thus, when a browser requested webform1.pdf, my
    application would process it as an asp.net page and the end result
    being it would return an actual PDF to the browser and the browser
    would open it in Adobe Acrobat.

    However, it appears that IIS is IGNORING my PDF application mapping
    and instead, it is procesing my webform1.pdf as a normal text file,
    instead of executing the script within it. I even tried mapping a
    neutral file extension, such as .test to the ASP.NET dll, but I got
    the same disappointing result.

    Does anyone know any way around the application mapping issue? Or
    better yet, understands how to deliver an asp.net-dynamically created
    PDF back to a browser so that it will open in Adobe Acrobat?

    Thanks
    David Guest

  2. Similar Questions and Discussions

    1. .x32 file extension
      Greetings, I have a .x32 file extension that I'm trying to open. The info on the internet says I can open it via Director (don't have), Flash...
    2. How do I insert an extension into a DW file.
      I am new to Dreamweaver. I have downloaded Web Photo Album 2.2 for Dreamweaver 8 and MX 2004, V2.2.6 from ... ...
    3. How to get the file-extension?
      Hi, Would like to query the extension of a file. The result/return should looking like this "doc, txt, avi". Is there a Xtra or a special kind of...
    4. Is .dcr extension = Director file extension ?
      I'm a newbie and saw some files on a website ending in .dcr... 1 - Is the .dcr file type a Macromedia Director file? 2 - Does it take the...
    5. apache 1.3.x and the php file extension
      A curious observation: I have my apache web server configured for the PHP apache module to parse files ending in the .php extension. nothing...
  3. #2

    Default How to map the .PDF file extension to the ASP.NET dll

    I think I had roughly the same problem when I wrote a web
    service to convert tif's to pdf's - the only way I could
    return a pdf, even after setting the content type, was to
    set the last 4 characters in the url to ".pdf" - it's
    stupid but it did the trick.
    >-----Original Message-----
    >Should you be able to map a any file extension to the
    ASP.NET dll and
    >have it execute ASP.NET script, just like an .aspx page,
    when it is
    >requested by a browser. If not, why bother giving us the
    ability to
    >create application mappings.
    >
    >I have an .aspx page that calls an SAP function which
    returns an
    >actual PDF to my calling .aspx. My .aspx then returns
    that PDF result
    >to the browser.
    >
    >When a browser requests that .aspx page, if I try to
    return that PDF
    >result as a response back to the calling browser, the
    browser does not
    >recognize it as a PDF (thus loading up Adobe Acrobat,
    etc.). This is
    >even after I have set the content type
    to "application/pdf".
    >
    >The browser is smart enough to know that this isn't a
    typical HTML
    >page, so it asks me if I want to Open or Save or Cancel
    this document.
    > If I click Save, then it tries to save it as an .aspx
    document, which
    >I understand, but I do not want to happen. I'd rather it
    at least try
    >to save it as a PDF. If I click Open, then it quite
    naturally tries
    >to open it as an .aspx page, which means it opens up the
    PDF results
    >in Visual Studio, which is also not what I want.
    >
    >So I was trying to figure out how I can get a browser to
    request a
    >file that can dynamically create a PDF using ASP.NET
    script AND have
    >the browser know that the response is a PDF and thus,
    open it up in
    >Adobe Acrobat.
    >
    >I am assuming at this point that the only way a an
    unknown user's
    >browser can reliably open up a file within Adobe is if it
    has the
    >actual PDF extension. I then decided to create a special
    web
    >application where I would map the .PDF extension to the
    ASP.NET dll in
    >my application mappings. Then, I would rename my
    webform1.aspx file
    >to webform1.pdf. Thus, when a browser requested
    webform1.pdf, my
    >application would process it as an asp.net page and the
    end result
    >being it would return an actual PDF to the browser and
    the browser
    >would open it in Adobe Acrobat.
    >
    >However, it appears that IIS is IGNORING my PDF
    application mapping
    >and instead, it is procesing my webform1.pdf as a normal
    text file,
    >instead of executing the script within it. I even tried
    mapping a
    >neutral file extension, such as .test to the ASP.NET dll,
    but I got
    >the same disappointing result.
    >
    >Does anyone know any way around the application mapping
    issue? Or
    >better yet, understands how to deliver an asp.net-
    dynamically created
    >PDF back to a browser so that it will open in Adobe
    Acrobat?
    >
    >Thanks
    >.
    >
    dave Guest

  4. #3

    Default Re: How to map the .PDF file extension to the ASP.NET dll

    You should be able to do this by setting the content-type appropriately,
    then the web browser understands that it is a PDF and will open it. Now
    there's two caveats: one, it used to be, the user could set in IE whether
    an application such as Adobe should open in IE or in its own window. Don't
    know that that is an option anymore.

    But more importantly, IE6 does not handling the streaming of PDFs well at
    all. The changing content-type throws it for a loop most times. Someone
    posted a workaround here a few months ago, but it was rather hokey and
    assumed certain performance values.....that said, I link directly to a PDF
    now, or redirect to it in the URL, after creating a temp file on my server.
    Too many issues with IE...

    But if interested, here's a little intro into setting the content-type,
    attachment, etc.:

    [url]http://www.ondotnet.com/pub/a/dotnet/2002/04/01/asp.html[/url]





    On 16 Jul 2003 15:23:45 -0700, David <dmiratsky@yahoo.com> wrote:
    > Should you be able to map a any file extension to the ASP.NET dll and
    > have it execute ASP.NET script, just like an .aspx page, when it is
    > requested by a browser. If not, why bother giving us the ability to
    > create application mappings.
    >
    > I have an .aspx page that calls an SAP function which returns an
    > actual PDF to my calling .aspx. My .aspx then returns that PDF result
    > to the browser.
    >
    > When a browser requests that .aspx page, if I try to return that PDF
    > result as a response back to the calling browser, the browser does not
    > recognize it as a PDF (thus loading up Adobe Acrobat, etc.). This is
    > even after I have set the content type to "application/pdf".
    >
    > The browser is smart enough to know that this isn't a typical HTML
    > page, so it asks me if I want to Open or Save or Cancel this document.
    > If I click Save, then it tries to save it as an .aspx document, which
    > I understand, but I do not want to happen. I'd rather it at least try
    > to save it as a PDF. If I click Open, then it quite naturally tries
    > to open it as an .aspx page, which means it opens up the PDF results
    > in Visual Studio, which is also not what I want.
    >
    > So I was trying to figure out how I can get a browser to request a
    > file that can dynamically create a PDF using ASP.NET script AND have
    > the browser know that the response is a PDF and thus, open it up in
    > Adobe Acrobat.
    >
    > I am assuming at this point that the only way a an unknown user's
    > browser can reliably open up a file within Adobe is if it has the
    > actual PDF extension. I then decided to create a special web
    > application where I would map the .PDF extension to the ASP.NET dll in
    > my application mappings. Then, I would rename my webform1.aspx file
    > to webform1.pdf. Thus, when a browser requested webform1.pdf, my
    > application would process it as an asp.net page and the end result
    > being it would return an actual PDF to the browser and the browser
    > would open it in Adobe Acrobat.
    >
    > However, it appears that IIS is IGNORING my PDF application mapping
    > and instead, it is procesing my webform1.pdf as a normal text file,
    > instead of executing the script within it. I even tried mapping a
    > neutral file extension, such as .test to the ASP.NET dll, but I got
    > the same disappointing result.
    >
    > Does anyone know any way around the application mapping issue? Or
    > better yet, understands how to deliver an asp.net-dynamically created
    > PDF back to a browser so that it will open in Adobe Acrobat?
    >
    > Thanks
    >


    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
    Craig Deelsnyder [MVP] Guest

  5. #4

    Default Re: How to map the .PDF file extension to the ASP.NET dll



    Thanks for the reply. Could you briefly describe how you went about
    adding .pdf to the URL. Are you doing this in the response object?

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Dave M. Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139