iis 7 System.Web.AspNetHostingPermission SecurityException
Raj and I ran into this one today while trying to load a web app on our new Server 2008 R2 box. The box is new and just had all it’s updates, so we started down the old IIS permissions route, but it lead us nowhere. After some searching, we find an answer that lead us to the real problem. We found the solution on this forum post by Tom Moser where he wrote:
‘I was able to fix this same problem by setting “Load User Profile” to TRUE on the Application Pool serving the MVC app.
Process mon showed me that the worker process was looking for the SID of a user under HKLM\Software\Microsoft\Windows NT\Current Version\ProfileList\… but that it wasn’t found. On a hunch, I set it to load user profile and now it works. I’m still trying to understand why, though. Maybe I need to look at the developer’s code to understand that.’
Well, once we did that, we ended up with a different issue. Our web app was trying to use .NET framework 3.5 which wasn’t installed on the server. It seems, that by setting ‘Load User Profile’ to True, it allowed the app to try to get to the framework and give us the real problem that it wasn’t installed. It was really a true error message hidden behind an error message pertaining to permissions. Tom found out in his app the same thing happened, he found the true problem afterwards:
‘Turns out, the reason I was getting that exception in the first place was because their database wasn’t configured properly. After enabling “Load User Profile” it showed me a SQL exception informing me that the app pool ID didn’t have rights to the database. After giving rights to the database, I was able to set “Load User Profile” to false and the page loaded. Maybe that’s something to keep in mind while debugging MVC issues.’
After we installed .NET 3.5 on the server, the application worked and we turned the “Load User Profile” back to False and it continued working. At times during application launches you do run into error messages that don’t truly tell you what the final problem is, but at least this one didn’t take too long to figure out! You’d be amazed at the amount of time it takes to launch a simple web app because it works fine on the development box, but when it comes to pushing it to production, it just fails and the error messages don’t help at all. But I guess figuring this stuff out is why they pay Raj and I the medium bucks :)