Link to home
Start Free TrialLog in
Avatar of dcurry22
dcurry22Flag for United States of America

asked on

Using HTML in an ASP.Net page. <a href> tag - trying to open a local HTML document.

I've created an aspx page in my project.  I want to click on a link to open a document stored on my computer.  The screen loads, but when I click on the link nothing happens.  Some Google searching revealed that the syntax could be tricky.  I've tried some variations, but this one works in Foxfire, which one article stated, should give me my HTML ref.  

First, Any reason I can't do this?  Second, Any suggestions to correct this for a local machine?
path being my directory structure.  

<a href="file:///D:/path/Desktop/HELLOWORLD.html" target= "_blank">

Any help is appreciated.
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

You may be able to get that to work in a file you have loaded locally but not thru a web server.  If you put that file on a web server and load it with 'http://', then the link to the local file will not work.  Browser security prevents external web sites from loading local files.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dcurry22

ASKER

Thanks for the Response!  I believe I've figured it out.  I need to place the document inside the directory structure of my application.  Running the application on my PC, IIS won't allow me to go outside of the application's root directory, thus storing the document on my desktop, I can't access it through my application.

I understand the local vs. web server distinction in your answer.  I was just trying to use some different document handling options, and couldn't get it to work.  

Also, could you be a little more specific on which part of browsersec/wiki/Part 2 I should read?  Thanks, there's alot out there.
The reason there is a lot in that article is because each circumstance seems to have a slightly different rule.  I suggest you read the whole thing once.  You might look at Part 1 also.

It is always simplest to put the documents inside the web directories so you don't have to use "file://" to access them.
javascript window.open('C:\test\abc.pdf'); worked in my case.