Login failed for user IIS APPPOOL\DefaultAppPool

Again I got a Error.

Login failed for user iis APPPOOL\Default. I fixed this issue by running following sql script in sql server.


IF NOT EXISTS (SELECT name FROM sys.server_principals WHERE name = 'IIS APPPOOL\DefaultAppPool')
BEGIN
CREATE LOGIN [IIS APPPOOL\DefaultAppPool]
FROM WINDOWS WITH DEFAULT_DATABASE=[MISDB],
DEFAULT_LANGUAGE=[us_english]
END
GO
CREATE USER [WebDatabaseUser]
FOR LOGIN [IIS APPPOOL\DefaultAppPool]
GO
EXEC sp_addrolemember 'db_owner', 'WebDatabaseUser'
GO

Set your required database as default database.

 

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false”.

So when I am hosting ASP.NET MVC web site in iis 7 I got following error.

error1

So I followed following steps to get this solved.

Click “Start button”
in the search box, enter “Turn windows features on or off”
in the features window, Click: “Internet Information Services”
Click: “World Wide Web Services”
Click: “Application Development Features”
Check (enable) the features. I checked all but CGI.

Now it is solved. I think it might help you.