Click here to Skip to main content
12,066,222 members (54,703 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server , +
I am working on web application. Suddenly i got the error "System.Data.SqlClient.SqlException was unhandled by user code: Login failed for user 'IIS APPPOOL\DefaultAppPool". Can anybody help.
Posted 7-Mar-13 20:42pm
Comments
Maciej Los 8-Mar-13 17:22pm
   
Check that sql services were started...
anjankant 8-Mar-13 23:39pm
   
Yes, SQL Server services already working.
Maciej Los 9-Mar-13 12:44pm
   
See my tip: http://www.codeproject.com/Tips/543989/How-to-enum-SQL-Server-instances-in-network. Run exe and check the named instances of MS SQL Server.
anjankant 14-Mar-13 4:56am
   
Hello Maciej, Thank you for thee reply it couldn't resolve my problem.
25MadhavG 9-Dec-15 1:10am
   
try this link, i was also facing same problem and i overcome it with the help of this link
http://stackoverflow.com/questions/7698286/login-failed-for-user-iis-apppool-asp-net-v4-0
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

go to iis -> application pools -> find your application pool used in application -> click it and then click 'Advance Settings' in Actions panel. Find 'Identity' property and change it to localsystem.
Please mark as solution if it solve your problem.
  Permalink  
Comments
U@007 26-Apr-13 8:56am
   
it's correct 5+ :).
pratapyadav 23-Nov-13 6:03am
   
thanks
roni.net 21-Jul-14 16:21pm
   
Many thanks. The SOlution is very good
sha_server 27-Aug-14 3:48am
   
thanks for the resolution
Member 11230360 26-Nov-14 1:24am
   
Thank you.. it worked.
Amit K Khanchandani 12-Dec-14 13:15pm
   
Thank you, , for me it was Network Service
Member 10986425 22-Dec-14 14:14pm
   
Very Very Thank You Nice Answer............Thanks Alot
Member 10043290 17-Feb-15 15:05pm
   
sorry did you said this solution to run on local system or on the host?
jcpc91 25-Mar-15 13:30pm
   
this is bad solution never never run iis on local system
Member 11687760 13-May-15 10:05am
   
thank you!!!
Member 11969880 9-Sep-15 0:27am
   
thanks
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 9

With reference to following link:

http://www.asp.net/mvc/overview/deployment/visual-studio-web-deployment/deploying-to-iis[^]

Create a grant script for the new databases

When the application runs in IIS on your development computer, the application accesses the database by using the default application pool's credentials. However, by default, the application pool identity does not have permission to open the databases. So you have to run a script to grant that permission. In this section you create the script that you'll run later to make sure that the application can open the databases when it runs in IIS.



Run the following script:
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=[master], 
      DEFAULT_LANGUAGE=[us_english]
END
GO
CREATE USER [WebDatabaseUser] 
  FOR LOGIN [IIS APPPOOL\DefaultAppPool]
GO
EXEC sp_addrolemember 'db_owner', 'WebDatabaseUser'
GO
  Permalink  
Comments
Member 11332478 13-Jan-15 23:13pm
   
its not working to my system,tell me how to delete this procedure?
jcpc91 25-Mar-15 13:34pm
   
this not work 'IIS APPPOOL\DefaultAppPool' doesn't exist in windows server 2008 r2
Member 11608707 15-Apr-15 4:23am
   
many many thanks.It works!!
Member 11241204 4-Jul-15 4:49am
   
Great.... It works ....Many Thanks :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 6

Hi Everyone,
I got this solution after good workaround, follow the link where is complete solution IIS APPPOOL\DefaultAppPoo, here also Video who describes all process to resolve the issue

It worked fine for me.
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 8

Run This Script :

CREATE LOGIN [IIS APPPOOL\DefaultAppPool] FROM WINDOWS
GO
--USE Table Name
GO
CREATE USER [IIS APPPOOL\DefaultAppPool] FOR LOGIN [IIS APPPOOL\DefaultAppPool]
GO
EXEC sp_addrolemember 'db_datareader', 'IIS APPPOOL\DefaultAppPool'
GO
EXEC sp_addrolemember 'db_datawriter', 'IIS APPPOOL\DefaultAppPool'
GO
  Permalink  
v2
Comments
CHill60 22-Sep-14 17:56pm
   
Resolved a year ago!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160208.1 | Last Updated 30 Oct 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100