Many of the code samples in this chapter write or access files in a directory. Before you can access files in a directory from within an ASP.NET page, you need to check whether the necessary permissions have been granted for the directory.
By default, the ASP.NET process executes in the security context of the ASPNET user account. If this account does not have permissions to write a file to a directory, then you'll receive an access exception when you attempt to write a file. To avoid an access exception, you'll need to grant write permissions to either the ASPNET user account or the Users group (By default, the Users group includes the ASPNET user account).
To grant the necessary permissions for writing to a directory to either the ASPNET user account or Users group, follow these steps:
For more information on the ASPNET user account see Chapter 20, "Using Windows-Based Authentication."