1

I have an asp.net page with a hyperlink tag, the idea is that I want to be able to click on the hyperlink (which will have the address of a directory on the system) and be able to open up the directory.

My hyperlink tag is within a gridview and the code for it looks like this:

<asp:HyperLink ID="eFileHyper" runat="server" Text='<%#Bind("hyperlink")%>' NavigateUrl='<%#Bind("hyperlink")%>' Target="_blank"></asp:HyperLink>

I have some code in the back end that adds "file:///" to the start of the address, like this:

Dim dr As DataRow
Dim dt As DataTable
    dt = CType(Session("newEFileTable"), DataTable)

    dr("lastUpdated") = Now
    dr("hyperlink") = "file:///" & hyperLink.Text
    dt.Rows.Add(dr)

    ' Update session table
    Session("newEFileTable") = dt

    ' update gridview - This binds the Session to the gridview
    BindEFileData()

If I enter in a directory like this \\server\directory\subdirectory it appears as - file:/// \\server\directory\subdirectory and it works fine.

If I enter a directory as C:/directory/subdirectory it appears as file:///c:/directory/subdirectory but clicking on it does nothing.

Why would one of these work but the other doesn't?

Update The \\server\directory\subdirectory and C:/directory/subdirectory are unrelated. The C:/ one is of course local, the other one is an address to a file on the server.

Him_Jalpert
  • 2,476
  • 9
  • 31
  • 55

1 Answers1

0

The latest versions of browsers disable links that point to local content (unless the link is in a file) as a security feature.

See Workaround for href="file://///..." in Firefox

Also, search for "iis enable local file links" and you get lots of hits. It looks like you can work around this by disabling relevant IE security: https://superuser.com/questions/149068/how-to-add-a-local-file-to-trusted-zone-in-ie8. I can't test that right now as I'm at work and browser settings are locked down.

Community
  • 1
  • 1
Tony Hinkle
  • 4,706
  • 7
  • 23
  • 35