Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET + Access to the path is denied

Tags:

asp.net

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!

like image 207
Villager Avatar asked Oct 15 '22 14:10

Villager


2 Answers

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/

like image 151
Subhash Jakhar Avatar answered Nov 15 '22 06:11

Subhash Jakhar


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.

like image 24
Dan Herbert Avatar answered Nov 15 '22 05:11

Dan Herbert