Thursday, June 27, 2013

The requested page cannot be accessed because the related configuration data for the page is invalid error when hosting WCF service in iis

Very often while hosting a wcf service in iis we get the error "The requested page cannot be accessed because the related configuration data for the page is invalid ". The reason it cannot read the config file is because the process running your web app does not have permission to access the file/directory. So you need to give the process running your web app those permissions. The access rights should be fairly straightforward, i.e. at least Read, and, depending on your app, maybe Write. Above, you mention IUSR etc. not being in the properties for web.config. If by that you mean that IUSR is not listed in the security tab of the file then it's a good thing. One doesn't want to give IUSR any kind of permission to web.config. The role IUSR is an anonymous internet user. The file web.config should only be accessible through your application. You need to assign permissions for IIS_IUSRS on the local machine (but you don't have to assign for IUSR, in fact it will work even if you explicitly deny permissions). To assign permissions, just right click on the folder and on the security tab make sure to grant the correct permissions, and if the user is not listed then click "ADD", and enter IIS_IUSRS (and make sure that under "domain" the local computer is selected, or enter in the name fieldYourLocalComputerName\IIS_IUSRS), and then you are good to go.