Access to the path is denied while downloading the file in ASPX

Gani_tpt 1,506 Reputation points
2022-09-06T12:39:18.09+00:00

Access to the path is denied.

I am using simple aspx page for downloading the file and same will be hosting in IIS.

i am using below code.

APSX Page
---------
<asp:TreeNode Text="T1" Value="T1">
<asp:TreeNode Text="S1" Value="S1">
<asp:TreeNode Text="WinFileExe" Value="WinFileExe" ></asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>

ASPX.vb File

------------

dim filename as string
filename = "\winnet.winnq.intranet\CANADA\Check File\Exe\WinFileExe"
Response.ClearContent()
Response.AddHeader("Content-Disposition", "attachment; filename=" & filename)
Response.TransmitFile(filename) ==> getting error in Transmitfile
Response.Flush()

Getting Error Access to the path "\winnet.winnq.intranet\CANADA\Check File\Exe\WinFileExe" is denied.

But, we have given the specific access to the folder and given all the asp.net authorized access.

still i am getting the error.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,252 questions
{count} votes

1 answer

Sort by: Most helpful
  1. QiYou-MSFT 4,306 Reputation points Microsoft Vendor
    2022-09-07T09:00:19.97+00:00

    Hi @Gani_tpt ,
    First of all , I think the reason is that your file permissions may not be set correctly.
    The solution is as follows:

    1. Right-click folder, Security, add IUSR and IIS_IUSRS Security Control permissions.
    2. Right-click on the folder, General, to see if it is read-only. Remove the read-only property.
      Second, it may be that your permissions to this application on IIS Manage are not given to all access users, you can right-click your program on IIS Manage to select identity and configure it. For more help with IIS Manage, you can check out the following documentation.
      https://learn.microsoft.com/en-us/iis/get-started/getting-started-with-iis/getting-started-with-the-iis-manager-in-iis-7-and-iis-8

    Best regards,
    Qi You


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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