Reputation: 3891
I'm trying to run an asp.net 3.5 web application in IIS 7.
It gives the following error: Cannot read configuration file due to insufficient permissions
If I run the application pool with a local admin account, it works. I'm trying to make it work with the Network Service account. For that, I added the Network Service account to the IIS_IUSRS group and gave read permissions for IIS_IUSRS on the web application folder, which were also propagated to the web.config file.
Any idea on what may be wrong?
Thanks in advance
Upvotes: 1
Views: 662
Reputation: 3891
I managed to solve the problem.
The files were “encrypted”. In the file properties, General tab, Advanced, there is a checkbox to encrypt the file, and it was checked for all files in the solution. Even though we can browse and open the files normally in the file system, ASP.NET cannot access them. This solution was sent by a client, I’m not sure how it got like that.
Hint: if windows explorer lists your files in a different color, like green, it’s a sign something is not normal ;)
Thanks for all the help and ideas
Upvotes: 1
Reputation: 955
There's a couple of things I think you should do. First of all, think in your mind of .NET 3.5 as .NET 2.0 with some extra assemblies on the side, which is what it really is. Then remember that in IIS7 we have a new Integrated pipeline. So, what you want is to run using the Classic pipeline. Next, check what the account is that you're running under, and give that account access to your website folders.
Here's how: 1. In IIS Internet Services Manager, open it up and select your website in the list of websites in the tree control. 2. Click on Basic Settings in the Actions bar, and you'll see what the application pool is. Click the SELECT button and you'll see that it says a Pipeline Mode and .Net framework version. You want it to say >net Framework Version 2.0 (even though you're on 3.5) and pipeline mode: Classic. 3. If you don't have an application pool available to choose from, then cancel out and go to Application Pools in the tree control on the left. Click Add Application Pool and add one that says 'Classing .NET AppPool" if its not already there. Select your new app pool and edit its basic settings to set it to .net framework version 2.0.50727 and managed pipeline mode set to Classic. Click ok. 4. Now click on advanced settings. Unless all your assemblies are 64 bit then make sure Enable 32-Bit applications is set to TRUE. Managed Pipeline Mode will say Classic. *PAY ATTENTION TO THIS PART: * The IDENTITY field tells you what user account the website is running under so you know what will need access permission to the root of your website with web.config. Set this to "NetworkService" and click OK. 5. Now go back to your website in the tree view, and go to Basic Settings again, and set the application pool to the Classic pipeline one you just set up. 6. Now go to the windows folder where your site is and give read+execute permissions to "NETWORK SERVICE".
Voila! Done.
Easy peasy lemon squeezy. It's easy when you know how anyway!
Upvotes: 0
Reputation: 28426
I believe the account needs at least read permissions to the applicationhost.config file on the machine (which is stored under %windir%\system32\inetsrv\config.
Upvotes: 0