.NET Framework - Open PDF File from Hyperlink control

Asked By Mik on 29-Sep-07 07:59 PM
Hi. I see a lot of threads regarding this, but none of them seem to present a
solution.

How can I open a PDF document (located outside of the web application), via
a Hyperlink control.  Currently I'm setting the NavigateURL property of the
hyperlink equal to the network path to the document, but this doesn't work.

Can anyone offer a solution?

Thanks
Mike




Cowboy \(Gregory A. Beamer\) replied on 29-Sep-07 10:07 PM
You cannot point to a network location if you are using a drive designation.
If this is an Intranet application, you can use a UNC, but I would not go
this direction unless every person hitting the site has access to that drive
location, or it will break for some.

If you are trying to display a file on the web server, but outside of the
file directory, you would be best to do a google search for creating a file
server or file serving page, or something similar. The basic idea here is
set the MIME type to the correct type for the file you are serving and then
stream out the bits. I will see if I can find a link a bit later.

I saw someone recently who was trying to copy files to a web directory and
link, but that is not the best solution.

One other option is to create a virtual directory in IIS that points to the
file location (if on that server) and link as if it was part of the website.
That works, but you will also have to give access to the web user or it will
not serve the file. You can then use the Membership bits from ASP.NET to
secure the file(s), if necessary.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
*************************************************
Mark Rae [MVP] replied on 29-Sep-07 10:13 PM
That's right - NavigateURL, as its name suggests, needs a URL e.g.
http://.........


Move the PDF into the virtual directory, or place it in a location which is
accessible via a URL...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Brian Simmons replied on 01-Oct-07 10:39 AM
Hi Mike,

I asked a similar question a couple of weeks back, and got some really good
responses/answers.

Here's the thread (watch the wrap):
http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/dc58c127230aef69/9a470a5472543e94?lnk=st&q=&rnum=1#9a470a5472543e94

hth,
Brian