Hyperlink to open a file

Stimulsoft Reports.NET discussion
Post Reply
Morgan
Posts: 11
Joined: Wed Jun 05, 2013 3:52 pm

Hyperlink to open a file

Post by Morgan »

So, one of the requests I got for a report was to include a link that could open a file. This is assuming the file path is supplied correctly; the report will just be taking that from a stored database, and that part works fine. However, I can't find a way to get a hyperlink in the report that will open the path. I tried a number of things, but the two cases it basically came down to was just putting the file location into the Hyperlink value of the Interaction option, which resulted in an error from the browser when clicked, and to try using the format "file:///C:/filepath/picture.jpg" which did nothing when clicked. Trying to use HTML in the Hyperlink value just broke a lot, so I assume that is not intended use. Is there a way to get this to work so it opens the file using the browser when clicked? Again, we can assume the file path is valid and the user has permissions; I verified that is true for my testing.

I'm not sure if this is doable through Stimulsoft but it does work in principle through the browser; copying and pasting the hyperlink into the browser's url bar opened the file just fine.


Thanks,
-Morgan
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Hyperlink to open a file

Post by Alex K. »

Hello,

We couldn't reproduce this bug.
Can you please send us a sample project which reproduce the issue for analysis.

Thank you.
Morgan
Posts: 11
Joined: Wed Jun 05, 2013 3:52 pm

Re: Hyperlink to open a file

Post by Morgan »

I'm not certain this is a bug, exactly, I'm just not sure what syntax is needed for it.

For example, I want to use a Stimulsoft report to open a file in a known location, say C:\Temp\example1.jpg. I give this location (as a string) to the report, and it displays it for the user. Displaying works fine, but when I put this string into the "Interaction -> Hyperlink" property, it doesn't work as-is; clicking opens a new window and the browser returns an error ("The address wasn't understood" i.e. the browser doesn't know it's a file). When I tried prefixing with "File:///" to tell the browser it was a file, then nothing happened when I clicked the link.

I tried using HTML to get to the file, but Stimulsoft doesn't seem to allow <a> tags that are clickable. This is probably for security reasons and a good idea, but it means that won't work for what I need either. The attached report uses <a href="file:///C:\Temp\example1.jpg">Open Link </a> as the HTML option, but without the "Interaction -> Hyperlink" property set, the link can't be clicked. When I do include the above HTML in the Hyperlink field, it has unexpected behavior, apparently sending the HTML as a link to the browser like: "http://[site_folder]/<a href="file:///C:\Temp\example1.jpg">Open Link </a>" which the browser returns the error "A potentially dangerous Request.Path value was detected from the client" when clicked.

Is there a way to get this to work correctly using the "Interaction -> Hyperlink" property of the text box? We've gotten this to work for webpages just fine, but not files. If Stimulsoft is not designed to send files to the browser this way, that's fine, but I would like confirmation of that.
Attachments
Simple file I used for testing. Place in C:\Temp (you will have to create the directory) to test the links in the attached report. Or don't, since the report won't successfully open the file anyway. If you do place it in the correct location then entering &quot;C:\Temp\example1.jpg&quot; into any browser will open the file, which is what I want Stimulsoft to do through a clickable link.
Simple file I used for testing. Place in C:\Temp (you will have to create the directory) to test the links in the attached report. Or don't, since the report won't successfully open the file anyway. If you do place it in the correct location then entering "C:\Temp\example1.jpg" into any browser will open the file, which is what I want Stimulsoft to do through a clickable link.
example1.jpg (11.88 KiB) Viewed 3083 times
Testing file links.mrt
(14.96 KiB) Downloaded 288 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Hyperlink to open a file

Post by Alex K. »

Hello,

Can you please clarify on which side you show the report. If you show report on the server, the path to the image takes on the server side - the image should be placed on the server.

Thank you.
Morgan
Posts: 11
Joined: Wed Jun 05, 2013 3:52 pm

Re: Hyperlink to open a file

Post by Morgan »

The report is served up in the browser, so the user is currently in their chosen browser when accessing the report, and the browser is on their local machine (we only support IE9+, FireFox, and Chrome, so this doesn't have to work in IE8 or earlier or Safari). We've gotten the reports to successfully open other pages of our program by using the "Interaction -> Hyperlink" property, but I couldn't get this working for Files. Copy-pasting the file location into the Browser's navigation bar does work, but the request is to do this with a single click inside the report.

Thanks,
-Morgan
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Hyperlink to open a file

Post by HighAley »

Hello, Morgan.

Unfortunately, it's forbidden to open local files from the page by security reasons.
If you use the same link on any other page you will not able to open the file.

Thank you.
Morgan
Posts: 11
Joined: Wed Jun 05, 2013 3:52 pm

Re: Hyperlink to open a file

Post by Morgan »

I thought that was the case, but our client was convinced otherwise so I needed more proof.

Thanks for clearing that up.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Hyperlink to open a file

Post by HighAley »

Hello.

This is made to avoid running any malware.
Let us know if you need any additional help.

Thank you.
Post Reply