Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open physical file on the server using ASP.NET

I want to open a physical file on the server on HyperLink click.

<asp:HyperLink ID="HyButton1" Target="_blank" NavigateUrl='<%#Eval("FullPath") %>' runat="server" Text="Open File" ></asp:HyperLink>

"FullPath" is like "E:\PINCDOCS\Mydoc.pdf"

Currently in Chrome i'm getting the error.

Not allowed to load local resource:

Can this be done or any other alternative solution?

like image 276
chamara Avatar asked Mar 15 '26 07:03

chamara


1 Answers

The physical file should be located within an IIS Web Site, Virtual Directory or Web Application. So you'd need to create a virtual directory to E:\PINCDOCS. See here for instructions: http://support.microsoft.com/kb/172138

Then in your code behind you can use code like: http://geekswithblogs.net/AlsLog/archive/2006/08/03/87032.aspx to get a Url for the physical file.

like image 181
Philip Pittle Avatar answered Mar 16 '26 20:03

Philip Pittle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!