Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read configuration file due to insufficient permissions

I've recently encountered an error trying to host my asp.net site with IIS. I have found a solution that many swear by.

Solution:

  1. Add IIS_IUSRS with Read permission on files in the folder
  2. Change IIS authentication method to BasicAuthentication
  3. refresh the website. It will work

(http://vivekthangaswamy.blogspot.com/2009/07/aspnet-website-cannot-read.html)

What do I add to my web.config file though? I've never had to edit it before. Here is its current contents:

<?xml version="1.0"?> <!--   For more information on how to configure your ASP.NET application, please visit   http://go.microsoft.com/fwlink/?LinkId=169433   --> <configuration>     <connectionStrings>   <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"    providerName="System.Data.SqlClient" />  </connectionStrings>  <system.web>   <compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>     </system.web> </configuration> 

My error is:

Config Error: Cannot read configuration file due to insufficient permissions
Config File: \?\C:\Users*****\Documents\Visual Studio2010\WebSites\PointsForTime\web.config

like image 654
Freesnöw Avatar asked Apr 10 '11 23:04

Freesnöw


People also ask

How to fix cannot read configuration file due to insufficient permissions?

Go to the parent folder, right-click and select Properties. Select the Security tab, edit the permissions and Add. Click on Advanced and the Find Now. Select IIS_IUSRS and click OK and OK again.

Is was not able to process configuration for the Web site or application?

Things you can try:Ensure that the NTFS permissions for the web. config file are correct and allow access to the Web server's machine account. Check the event logs to see if any additional information was logged. Verify the permissions for the DLL.

Where is redirection config located?

redirection. config is a file that lives in the IIS configuration directory, typically %SystemRoot%\System32\inetsrv\config .


2 Answers

There is no problem with your web.config. Your web site runs under a process. In iis you can define the identity of that process. The identity that your web site's application pool runs as (Network Services, Local System, etc.), should have permission to access and read web.config file.

Update:

This updated answer is same as above, but a little longer and simpler and improved.

First of all: you don't have to change anything in your config file. It's OK. The problem is with windows file permissions.

This problems occurs because your application can not access and read web.config file.

Make the file accessible to IIS_IUSRS group. Just right click web.config and click properties, under security tab, add IIS_IUSRS.

So what is this IIS_IUSRS thing?

Your web site is like an exe file. Just like any exe file, it should be started by a user and it runs according to permissions assigned to that user.

When your site is started in IIS, Application Pool of your web site is associated with a user (Network Services, Local System, Etc. ...) (and can be changed in IIS)

So when you say IIS_IUSRS, it means any user (Network Services, Local System, Etc. ...) that your site is running as.

And as @Seph mentioned in comment below: If your computer is on a domain, remember that IIS_IUSRS group is a local group. Also make sure that when you're trying to find this user check the location it should be set to local computer and not a corporate domain.

like image 158
Afshin Gh Avatar answered Oct 17 '22 02:10

Afshin Gh


I had what appeared to be the same permissions issue on the web.config file.

However, my problem was caused by IIS failing to load the config file because it contained URL rewrite rules and I hadn't installed the IIS URL rewrite module on the new server.

The solution was to install the rewrite module.

like image 27
Jarrod Avatar answered Oct 17 '22 01:10

Jarrod