Ask a Question related to ASP.NET General, Design and Development.
-
David #1
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
-
.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... -
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 ... ... -
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... -
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... -
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... -
dave #2
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.
ASP.NET dll and>-----Original Message-----
>Should you be able to map a any file extension to thewhen it is>have it execute ASP.NET script, just like an .aspx page,ability to>requested by a browser. If not, why bother giving us thereturns an>create application mappings.
>
>I have an .aspx page that calls an SAP function whichthat PDF result>actual PDF to my calling .aspx. My .aspx then returnsreturn that PDF>to the browser.
>
>When a browser requests that .aspx page, if I try tobrowser does not>result as a response back to the calling browser, theetc.). This is>recognize it as a PDF (thus loading up Adobe Acrobat,to "application/pdf".>even after I have set the content typetypical HTML>
>The browser is smart enough to know that this isn't athis document.>page, so it asks me if I want to Open or Save or Canceldocument, which> If I click Save, then it tries to save it as an .aspxat least try>I understand, but I do not want to happen. I'd rather itnaturally tries>to save it as a PDF. If I click Open, then it quitePDF results>to open it as an .aspx page, which means it opens up therequest a>in Visual Studio, which is also not what I want.
>
>So I was trying to figure out how I can get a browser toscript AND have>file that can dynamically create a PDF using ASP.NETopen it up in>the browser know that the response is a PDF and thus,unknown user's>Adobe Acrobat.
>
>I am assuming at this point that the only way a anhas the>browser can reliably open up a file within Adobe is if itweb>actual PDF extension. I then decided to create a specialASP.NET dll in>application where I would map the .PDF extension to thewebform1.aspx file>my application mappings. Then, I would rename mywebform1.pdf, my>to webform1.pdf. Thus, when a browser requestedend result>application would process it as an asp.net page and thethe browser>being it would return an actual PDF to the browser andapplication mapping>would open it in Adobe Acrobat.
>
>However, it appears that IIS is IGNORING my PDFtext file,>and instead, it is procesing my webform1.pdf as a normalmapping a>instead of executing the script within it. I even triedbut I got>neutral file extension, such as .test to the ASP.NET dll,issue? Or>the same disappointing result.
>
>Does anyone know any way around the application mappingdynamically created>better yet, understands how to deliver an asp.net-Acrobat?>PDF back to a browser so that it will open in Adobe>
>Thanks
>.
>dave Guest
-
Craig Deelsnyder [MVP] #3
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
-
Dave M. #4
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



Reply With Quote

