5

I have an ASP.NET application that attempts to write files on the web server during runtime. In my development environment, this works. However, when I deploy it to the production server, and I execute the code, I receive an error that states:

"Access to the path 'C:\Inetpub\wwwroot\MyWebApp\DirToWriteTo\' is denied."

My production server is a Window Server 2003 machine. The web application is set to allow anonymous access via the IUSR_TEMPLATE account.

What am I doing wrong?

Thank you!

Santosh Panda
  • 7,235
  • 8
  • 43
  • 56
Villager
  • 6,569
  • 22
  • 65
  • 87

4 Answers4

2

You need provide the grant permissions to NETWORK SERVICE user.

you can check this link:-

http://repeatgeek.com/technical/asp-net-access-to-path-is-denied/

1

The most likely problem is that your anonymous user does not have write access to the location.

What I would do is create a web.config entry for the location you want to write to and use that config key as your writable directory. This will allow you to have separate configuration for your production server and your development machine, if needed.

Next, just give write access to the directory defined in your configuration to the user IUSER_TEMPLATE, or as Thorarin said the Network Service, in which case you should set up identity impersonation in your Web.config so that you can specify the user (unless you configure the user through the app pool). That should fix the problem.

Dan Herbert
  • 99,428
  • 48
  • 189
  • 219
  • 1
    Only if the `Web.config` has an `` in it's `` section. Otherwise the identity set for the application pool is used. By default, that is *Network Service* (which has very limited access) – Thorarin Aug 02 '09 at 18:35
  • That's true. I didn't think of that initially. I'll update my answer to include that. – Dan Herbert Aug 02 '09 at 19:01
1

If you have Windows 2008 or above, try giving write permissions to IIS_IUSRS.

(Network Service has also worked for me in the past. From what I read here, it depends on the Server OS.)

enter image description here

James Lawruk
  • 30,112
  • 19
  • 130
  • 137
0

In my case, Visual Studio 2015 changed an existing project's IIS AppPool user to the default of DefaultAppPool, which gave me permission errors, configuration errors, role provider errors, and null reference errors. After discovering this and changing it back to the application pool that the folder permissions were set to, things started working again.

Suncat2000
  • 966
  • 1
  • 12
  • 15