Web.Config - Cannot read configuration file due to insufficient permissions - asp.net

I am getting the error:
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x80070005
Config Error Cannot read configuration file due to insufficient permissions
Config File \\?\C:\inetpub\wwwroot\web.config
The file itself has full permissions for IUSR. IIS is running its app pool under ApplicationPoolIdentity. I did a file monitor on the file, and I see this:
9:04:43.8035456 AM w3wp.exe 8104 CreateFile C:\inetpub\wwwroot\Web.config ACCESS DENIED Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, AllocationSize: n/a
No idea why I am getting this error... Any ideas?

Try giving read/write access to these accounts to the root folder of your Web application and all files/subs within:
NETWORK, NETWORK SERVICE, and of course IIS_IUSRS

I found that adding the mymachine/USERS with full permissions to C:\inetpub\wwwroot fixed the issue.
The problem was caused because I shared some sites content inside C:\inetpub\wwwroot with other developers. This must have changed permissions and broke my IIS completely.

First, make sure IUSR has Read permission on the config file (which I believe you have done that)
Then, change IIS authentication method to BasicAuthentication
If still not working, probably the .config extension is not properly installed in IIS.
Try all 3! Good luck!
EDIT: Forget to ask you, what kind of appliation is it?

I just came across this and was unable to find applicationpoolidentity as an account in order to add it to the folder security. I changed the application pool identity from applicationpoolidentity to Local Service and the site ran fine.

I was copying a live WordPress site to my local machine for editing/updating when this IIS error occurred. Changing permissions did nothing.
In my case, simply deleting the web.config did the trick.

I ran into this issue again today. This time, no amount of granting permissions worked (tried all the usual accounts, everybody, read-only, modify, full control).
Closed processes, restarted IIS, full reboot. No results.
Eventually changed the owner from "Administrators" to myself, and things fell into place.
I usually run Visual Studio at Admin level (using my own account) because I like to use the local IIS for hosting / debugging ASP.NET sites. Perhaps that caused new files to be owned by \Administrators, which in turn may have limited access to those files by the IIS or App Pool processes.
My DefaultAppPool identity is set to load the user profile. I don't know at what point the session manager applies UAC / permissions drops and whether user profile loading has any influence on this. Food for thought...

Related

Cannot read configuration file due to insufficient permissions on web.config [duplicate]

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Error Code : 0x80070005
Config Error : Cannot read configuration file due to insufficient
permissions
When add new web application in IIS 7.5 and run it, this page shown to me, how to solve this problem win7 ultimate visual studio 2010
The message is clear.
Cannot read configuration file due to insufficient permissions
How to solve it.
Every asp.net application is run under one pool assigned to it, and each pool is run under a specific account.
Open the IIS, locate the pool under which your app is try to run, see the user that is assigned to that pool, and give read permissions to that user on your full site directory tree.
Especial for the web.config
The web.config, its the configuration file that message says, must have (and) write permissions.
So you locate web.config on the root of your site, right click on it, go to permissions and give on the pool-user, the write capability. The pool user, is the user under the witch the pool is run, as I explain below.
More details
To been able to run a public asp.net site with IIS, each file on the directory must have permissions for two accounts.
One account that is permitted for public access, and the account that assigned to that application pool have.
To find/assing the first account you go to your iis site | Authentication | Edit, and see or change it as you see on that screen shot.
Now note that name and we going to find the user under with the pool run.
Go the your IIS Site and click on the Basic Settings to find the pool name, then go to the IIS | Application Pools and see the Identity column, and note the name of the user under the witch your site is run.
Now that we have the two users names we go to the root of the site and set the minimum of permissions that is the read as
Some Notes
If the IIS_Public_ACCESS_USER is not give read permission the site is run, but ask for password
On some directories you need and write permissions, if you let for example your users upload images, or keep on App_Data, some database files. Only for that directories you give and the write permissions to the IIS_POOL_USER.
Some directories, like the App_Data and App_Code have direct protection from asp.net and they not allow anyone from the client side to run or view whats is in there.
On the public directory that allow write access to your user add one web.config and totally disable all the running of asp.net files.
More to read for the directories that give write permissions I've been hacked. Evil aspx file uploaded called AspxSpy. They're still trying. Help me trap them‼
It looks like your IIS_User doesn't have the necesarry permissions to access your website in C:\Users....\Visual Studio 2012\Websites...
Also make sure your application is running the correct .NET version (2.0, 4.0, ...)

permission to change web.config in window azure

I deploy my application in azure successfully.In some case I have write some thing in my web.config file.But when I try to write in web.config I got permission problem.In local I have not any problem after give read/write permission to IIS User.
I search but unable to find any thing about read/write permission in azure.
Is there any way to give permission to read/write in web.config file.Or I am totally in wrong way.Thanks .
You're doing it wrong. Don't change the web.config file from inside the role because all the changes will be lost once the role or any of its instances is redeployed (which can happen for a number of reasons including a VM crash and later automatic recovery initiated by Azure platform).

Cannot read configuration file due to insufficient permissions

Okay, I realize there are many questions relating to this error, I have read several questions and answers without resolving my problem.
I have a MVC site that I'm trying to debug on local IIS web server.
I check the option to use local IIS in the project properties and I've created a virtual directory in IIS.
The error I get in Visual Studio is:
Unable to start debugging on web server.
In IIS i try browse the site but get the error:
Cannot read configuration file due to insufficient permissions
Config File \?\C:\Users\Mike\Documents\Visual Studio 2010\Projects\MvcApplication1\MvcApplication1\web.config
I've set permissions for the pool identity on the web.config and whole project folder.
I've tried localsystem identity, no luck!
Please help me resolve this. I've spent several hours trying to fix this.
I found that if granting read permission to IIS_IUSRS still does not help. You need to also check that the web.config file is not encrypted. You can see if the file name is green in Window Explorer, it means the file encrypted. You can also do right click at the file, select Properties… / General Tab / Advanced… Make sure the "Encrypt content to secure data" unchecked.
It works for me once I uncheck that Encrypt box.
Maybe this will help. Look here, here and here
You also might have to grant ISS_IUSRS right to C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config and then do a iisreset
Edit:
Do you have the right Application Pool Identities? Read more here
For local development I've used pritty straightforward solution - just set IIS Application Pool to LocalSystem, set permissions for site folder (ISS_IUSRS - all) and it's worked for me
I only ran into a different set of issues with IIS_IUSRS. So I just published the site under a whole different folder, off the root, and the issue went away!

ASP.NET/IIS7.5 Writing Log File Not Working (Permissions, UAC, Config., ???)

We're having trouble migrating our ASP.NET applications to Windows Server 2008 R2 x64 and IIS7.5. The problem is that our ASP.NET apps write log files, and these log files are not being written. The only way the apps write their log files is if I'm logged into the server as the local Administrator user or if I right click and run IE as Run as Administrator, neither of which is an acceptable solution for us.
Our platform is:
Windows Server 2008 R2 x64 (UAC setting is the default setting)
IIS7.5
ASP.NET 4.0 (using Windows authentication and impersonation, both on in web.config)
Our app gets installed to:
D:[appname]
[appnameWebSite] (all the .aspx, .dll, etc. files are in here)
\Log (the app tries to write the log file to this folder)
On the server:
Created new App Pool (name: [appname], .NET 4.0, Managed Pipeline Mode: Classic, Identity: ApplicationPoolIdentity, Load User Profile: False, all other properties are the defaults)
Created IIS application pointing to D:[appname][appnameWebSite] and added it the the new App Pool (Full trust level)
Have a domain user in local Administrators group
With all the configuration and default settings listed above, the ASP.NET app will not write the log file. The app appears to work fine in the browser, but no log.txt file.
To try to "fix" this issues, we've tried many things:
Tried Application Pool setting: Managed Pipeline Mode: Integrated
Tried Application Pool setting: Identity: NetworkService
Tried Application Pool setting: Identity: LocalSystem
Tried Application Pool setting: Load User Profile: True
Gave Users group full control to file system for our application folder structure (tried appname folder, tried Log folder only, tried appnameWebSite and Log folders only)
Gave IIS AppPool[appname] (matching the new App Pool) user full control to file system for our application folder structure (tried appname folder, tried Log folder only, tried appnameWebSite and Log folders only)
None of these things helped. Again, the app would run fine, just no log file created.
As mentioned above, the only way that the log file is created when the app runs is if we log into the server using the local Administrator account (which makes sense since he's a super user) or if we run IE as administrator and elevate privileges.
Any suggestions? Help? Questions?
Thanks!
I tried granting every permission possible and still wasn't getting any log files. Finally I came across this which suggested changing the ownership of my logfiles directory. I checked, and the directory ownership was set to SYSTEM. I changed it to Administrators and applied the change recursively. I bounced IIS, hit a webpage from the site in the browser, and now I have log files. Hooray!
Note: the thing that tipped me off was checking the System event log. I was getting 15006 errors saying "Owner of the log file or directory C:\inetpub\logfiles\W3SVC1\some.log is invalid. This could be because another user has already created the log file or the directory."
Well, after days of trying every IIS option, user and group accounts, file system permissions, Process Explorer, etc., I think we got it working:
We reset all our IIS app pool and web site settings to their default values
We also reset the folder/file system permissions on our Log folder to the default settings
Then we turned off Internet Explorer Enhanced Security Configuration on the server
And success! The log file is written as expected no matter what user is using the ASP.NET application, and no matter if they're running it on the server itself or from a workstation.
I don't know if turning off Internet Explorer Enhanced Security Configuration on the server is the "correct" thing to do or if it violates any best practices, but it seems to work for us.
Does anyone have anything to add?
I struggled with this one for a while. The ApplicationPoolIdentity is a member of the Users group and the Users group has limited access.
From Explorer, right-click on the folder where you are trying to write and go to Security. Click the Advanced button. you will see that Users have Read and Execute permission and the Users group may or may not have Special permissions. If not, Click on Change Permissions and give Users the ability to Create files / write data and Create folders / append data. This is restricted to this folder. I usially use a subfolder so that I not provide write access to my whole website.
Try creating log files again. This is the only permission that I needed to set to make it work.
For me the trick was giving write access for SYSTEM and Administrators not only to the log folder itself, but also every folder in the path. This is not how permissions usually work in Windows, but IIS appears to be really rather particular about it. Not that there is a good reason to remove these two from the ACLs to begin with.
If you suspect this to be the problem, check the Event Log under Windows Logs / System. This issue manifests itself as an Error entry from source HttpEvent, and reads "Unable to create log file C:\path\to\logs\W3SVC1\u_extend1.log. Make sure that the logging directory is correct and this computer has write access to that directory."
P.S. This is true for IIS 10 but may apply to other versions too.

ASP.NET + Access to the path is denied

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!
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/
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.
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.)
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.

Resources