?
Solved

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

Posted on 2006-06-13
5
Medium Priority
?
1,710 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 14

Accepted Solution

by:
Thandava Vallepalli earned 1500 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 25

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

766 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