Unable to open local files in Edge

fp2021 1 Reputation point
2022-02-17T12:18:35.38+00:00

I have a .NET 4.0 web application that allows users to view local files by clicking on hyperlinks from a gridview. The application is using "file://server/folder/document" to open network shared files. Everything works fine in Internet Explorer but the hyperlinks are not clickable in Edge. I believe "file://" is being blocked in modern browsers. Can someone offer any suggestions how to resolve this issue without having install browser extensions or modify security policies?

Protected Sub FileGrid_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles FileGrid.RowDataBound
    If e.Row.RowType = ListItemType.AlternatingItem Or e.Row.RowType = ListItemType.Item Then
        Dim fiCurrent As FileInfo = e.Row.DataItem
        Dim lnkFile As HyperLink = e.Row.FindControl("hlFile")
        lnkFile.NavigateUrl = "\\server\folder\"& fiCurrent.Name
    End If
End Sub

<asp:GridView ID="FileGrid"   runat="server">
    <Columns>
        <asp:TemplateField HeaderText="Attachment Name">
            <ItemTemplate>
                <asp:HyperLink ID="hlFile" runat="server" Target="_blank"></asp:HyperLink>
            </ItemTemplate>
        </asp:TemplateField>                               
    </Columns>
</asp:GridView>
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,281 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,289 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,580 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,846 Reputation points
    2022-02-17T16:09:41.753+00:00

    The chrome plug-in required to get local file links working.

    Your web server could act as a proxy, it could return server links that when clicked, return the file as an attachment. If the users need write access, then you could look at a WebDAV server.


  2. Yijing Sun-MSFT 7,071 Reputation points
    2022-02-18T06:37:38.657+00:00

    Hi @fp2021 ,

    works fine in Internet Explorer but the hyperlinks are not clickable in Edge.

    It's not an issue but a comman behavior of modern browsers that we can't link to file protocol from a page serving in http protocol for security reasons. I also find a post discussing about this. This behavior is by design.

    The best practice is serving the file you want to open on local network with http protocol and link it with http protocol. Then you can open it without any issue.

    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments