Using Microsoft.Web.Administration to programatically create web sites
I'm using Microsoft.Web.Administration to create new websites on IIS 7.5
Using mgr As New ServerManager() mgr.ApplicationPools.Add(applicationPoolName) ....
it will work fine when using visual studio debug mode (F5) which will run on localhost:61044 (or whatever port)
However, when running on production site (or localhost) the following permission error will come up:
Redirection.config/ Error: Cannot read configuration file due to insufficient permissions
I've tried setting READ permissions for IUSR and DefaultAppPool users for C:\Windows\System32\inetsrv\config (folder) and C:\Windows\System32\inetsrv\config\redirection.config (file)
I'm assuming it's a permission issue, but I have not figured out or found a solution.
when you are in vs the process is running as you... you could always test by setting the app pool user to an administrator. or just your user identity. Then once you know it works... tinker around with giving various permissions to the folder those files are in.
That being said... setting the app pool user to localsystem should solve the issue too. localsystem gives the process admin rights so this might not be appropriate if the app is externally facing. If it is an intranet app then it might be ok...
otherwise you will need to figure out the exact permissions you need which sorry I don't actually know.
I found Redirection.config in the path C:\Windows\System32\inetsrv\config, in my case I added the read permission to the IIS_Iuser and problem solved.