tags:

views:

70

answers:

6

Say I have this line in my aspx file

<li>
   <a href="../products/handout.pdf" target="_blank">
       Desktop and Laptop Installations
   </a> 
</li>  

My problem is that the pdf file is opened by IE , How can I force it to open in Adobe Acrobat ( the associated app basically ) is this doable at all or is this decided by IE and the associated app somehow TIA

+4  A: 

IE decides the associated application. In fact, Windows decides it. Making use of terminologies, the client side decides it. You are on the server side and cannot.

Amit
Hmm... The HTML/CSS/JavaScript code *is* client-side... (The browser downloads it to and executes it on the user's computer.) It just doesn't have the power to determine how the browser handles a PDF document.
Steve Harrison
@Steve: HTML/CSS/JS is client side.
Amit
+5  A: 

You can't. That is handled by the user's computer, not your code.

Jonathan Sampson
A: 

IE and windows are the deciding factor here not your link (as long as it has the standard .PDF extension).

codemypantsoff
+1  A: 

While you can't force it, you can make a recommendation to the user to right click the link and select "Save file as"

You could use the title attribute for that.

<a href="some.pdf" title="To save this file, right click, and select 'Save file as'">Some PDF File</a>

would display the title text when the user hovers over the link.

jonfhancock
acceptable answer ..
infant programmer
A: 

If you deploy this to IIS, you can use a linkbutton, handle it severside, and stream the PDF with the correct header to force acrobat to handle it.

Pierreten
+3  A: 

If you were running on Apache (which it sounds like you're not) you could have the link point to something other than a real PDF. Have it point to a link like: href="/documents/blah.pdf" and use a rewrite for calls to this directory that points all requests to a script. Have that script parse the URL and get the file name at the end. Have a directory like "real_documents" and have the script fetch the pdf contents from the real pdf in that directory. Set your Content-Disposition header to Attachment. A compliant browser will treat the file like one that is being downloaded instead of one that is being opened as a link. The user will get a "would you like to save or run" and then the file is opened in whatever external program they have set to handle that file type (as opposed to how the browser handles the MIME type).

However, that is a lot of trouble to go to simply to make the end user get an experience they probably won't want.

Sorry I don't know the exact terminology in IIS, but I'm sure there is a near 1-to-1 version of ModRewrite for it.

Anthony