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

Posted on 2012-09-11
Last Modified: 2013-04-09
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.
Question by:dcurry22
    LVL 82

    Expert Comment

    by:Dave Baldwin
    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.
    LVL 82

    Accepted Solution

    LVL 1

    Author Comment

    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.
    LVL 82

    Expert Comment

    by:Dave Baldwin
    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.
    LVL 7

    Expert Comment

    javascript'C:\test\abc.pdf'); worked in my case.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Many companies are making the switch from Microsoft to Google Apps ( Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
    User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
    Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
    The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now