ASP.NET Core 3.1 app deployed on IIS not connecting to local db but its connecting to something. The app is working Application 'C:\inetpub\wwwroot\retailbanking\' started successfully.
on windows logs. I have a bunch of users registered in dbo.aspnetusers
but when I launch the website from IIS none of the users I try to login with are registered. I am also able to recreate these users but I have no idea where they are being stored in since my db I'm using is not being populated. My appsettings.json
is correct since everything works when I run it but when deploying it, it doesnt seems to connect correctly.
appsetting.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Default Connection": "Server=(localdb)\\MSSQLLocalDB;Database=Retail Banking;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
applicationHost.config
<applicationPoolDefaults managedRuntimeVersion="v4.0">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</applicationPoolDefaults>
I've tried both local system and applicationpoolidentity.
CodePudding user response:
By default LocalDb instances are not shared between users. So either run the app as yourself, or move the database to a shared instance of LocalDb instance, or a Service-based install of SQL Server Express Edition.
CodePudding user response:
You shouldn't use localdb when hosting in IIS. LocalDB is launched in the context of the user running it. On you dev box, that going to be YOU the "super user" with all rights etc.
LocalDB databases are owned and accessible by the user who creates it.
In IIS you don't have a Profile by default. While there are workarounds, they are all more or less dirty and not an option.
LocalDB is launched in the context of the user running it - and that's not really a practical for a working web site.
(LocalDB databases owned and accessed by the user who creates it (that would be you on your development computer - again the "super" admin of your computer))
In IIS you don't have a Profile by default. Messy workarounds are possible.
Install either SQL Server Express or the full version of SQL Server.
LocalDB is ONLY for easy development without requiring to install SQL Server Express or SQL Server full version.
For all practical purposes you want to have a running instance of SQL server.