title: Access shared folder from application deployed in IIS
body: <p>I have a problem when I try to access a file from a shared folder in a local network.<br>
  When I run the application in Visual Studio it works fine and I can download the file, but when I deploy the application to IIS, it simply doesn´t work.<br>
  I don´t understand why, cause I give full permissions to all users, including NETWORK SERVICE and IIS_USR.<br>
  I'm currently using my computer to test this. It has Windows 7 and running IIS 7.5. The shared folder I'm trying to access is on a Windows Vista installation which doesn´t have IIS installed.</p>
  
  <p>The code to download file is this:</p>
  
  <pre><code>protected void button_Click(object sender, EventArgs e)
  {
      Response.Clear();
      Response.ContentType = "application/octet-stream";
      Response.AddHeader("Content-Disposition", "attachment; filename=S10.png");
      Response.WriteFile(@"\\192.168.1.82\Machine\file.png");
      Response.End();
  }
  </code></pre>
  
  <p>and it gives me the following error:</p>
  
  <blockquote>
    <p>Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.</p>
    
    <p>Exception Details: System.UnauthorizedAccessException: Acesso negado
    ao caminho '\192.168.1.82\Machine\file.png'.</p>
    
    <p>ASP.NET is not authorized to access the requested resource. Consider
    granting access rights to the resource to the ASP.NET request
    identity. ASP.NET has a base process identity (typically
    {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and
    the configured application pool identity on IIS 7.5) that is used if
    the application is not impersonating. If the application is
    impersonating via , the identity will be
    the anonymous user (typically IUSR_MACHINENAME) or the authenticated
    request user.</p>
    
    <p>To grant ASP.NET access to a file, right-click the file in Explorer,
    choose "Properties" and select the Security tab. Click "Add" to add
    the appropriate user or group. Highlight the ASP.NET account, and
    check the boxes for the desired access.</p>
  </blockquote>
  
  <p>Please someone could help me.
  Thanks in advance.</p>