Solved

how to location.href to a full filename (pdf file)

Posted on 2006-06-13
5
1,680 Views
Last Modified: 2012-06-21
When I click on a hyperlink for an asp.net file link utility I'm trying to write, I can't figure out how to get the file to open.

Is there something special I need to do to open files that are hyperlinked?

If the file is in the wwwroot during my test, I can open as long as it is not fully extended:

For example:

location.href=""MyFolder\report.pdf"""

That works.

But when I try to fully extend it, it doesn't work.

"location.href=""C:\Inetpub\wwwroot\MyProj\MyFolder\report.pdf"""

That doesn't work.

What am I doing wrong? Why can I shortcut to the file, but when I want to use the full filename, it doesn't work? Ultimately I want to point to files outside the wwwroot, but I'm starting here as a test.




0
Comment
Question by:TZych
5 Comments
 
LVL 14

Accepted Solution

by:
Thandava Vallepalli earned 500 total points
ID: 16897900
Hello,

>>but when I want to use the full filename, it doesn't work?

You should not put full file path in the location.href property.   wwwroot is the starting location of the webserver.  So web server doesn't know C:\Inetput location. It knows from only the wwwroot folder (i.e. root folder of the web server).  



>>Ultimately I want to point to files outside the wwwroot, but I'm starting here as a test.

You should not point the files which are outside of the wwwroot in location.href property...   As I explained you in above paragragh, web server file path starts from wwwroot folder.  So if you want to point outside wwwroot folder, you copy those files into wwwroot subfolders. then it works...

I hope you understand.....

Please let me know in case of any issues in this regard...

itsvtk
0
 
LVL 8

Author Comment

by:TZych
ID: 16897962
the webserver is the same machine where the files are.

it knows about D:\ and C:\

I have hyperlinked to them, but how do I open them with hyperlinkd?
0
 
LVL 8

Author Comment

by:TZych
ID: 16898017
Let me rephrase that.

The files are on the same machine as the webserver.

How can I open them via hyperlinks? I can see them as hyperlinks, but it won't open them.
0
 
LVL 24

Expert Comment

by:DBAduck - Ben Miller
ID: 16899252
What the problem is, is that when you try to use a href or a Hyperlink, you cannot reference c:\something\something.pdf because you are in a http context and the browser can understand that, but there is no file on your local machine with that path or name.  So the href is going to have to be /wwwrootname/folder/file.pdf instead.

For example:

location.href=""MyFolder\report.pdf"""

That works.
>> this works because it is relative to the wwwroot.

But when I try to fully extend it, it doesn't work.

"location.href=""C:\Inetpub\wwwroot\MyProj\MyFolder\report.pdf"""

That doesn't work.
>>> This does not work because of the href property being set to a physical path instead of a virtual path.

What am I doing wrong? Why can I shortcut to the file, but when I want to use the full filename, it doesn't work? Ultimately I want to point to files outside the wwwroot, but I'm starting here as a test.

>> so it should be
location.href="/MyProj/MyFolder/report.pdf"

Ben.
0
 
LVL 4

Expert Comment

by:indu_mk
ID: 16900577
if u want to give hyperlink to a file outside ur web site directory, u can create a virtual folder that directory ... say, for eg ur file is c:\something\something.pdf , make C:\something a virtual directory named "something" and give the hyperlink as http://localhost/something/something.pdf
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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