Forum Discussion
Hugo O. Ornelas
Apr 18, 2023Copper Contributor
ASP.Net Core 6 Web App - Fails to connect to database after published to on-prem IIS
Dear Community,
I started to learn .Net core and entity framework, and its great. I built a small webapp as a test with a database (SQL LocalDB) and locally on my dev machine, it works fine.
I publish to a folder location, then copy locally to a Windows 2019 Server and added a website on the server's IIS. The app will run the razor pages without a model, but the page that serves the model to add data or view data from the SQL database fails and the error is weird and it says there is no server found and cannot authenticate NT Authority\System. I made sure that SQL server express is installed and I can connect, I made sure localDB was added as a feature to the sqlexpress instance, etc., etc., My question is, do I have to do anything funky like wear a foil paper hat, to get this to work? I cant seem to find any documentation at all and youtube tutorials go through all the motions except publishing the app. Any help will be greatly appreciated.
- AddWebSolutionBrass ContributorHi Hugo O. Ornelas ,
After adding Encrypt=False to the connection string, it worked!!!
Best Regards,
AddWebSolution - expertopinionsa12Copper ContributorIt sounds like you have encountered a problem while trying to deploy your .NET Core web application with Entity Framework to a Windows 2019 server. Based on the error message you received, it seems that the application is unable to authenticate the NT Authority\System account to access the SQL LocalDB. Verify that the connection string used by your application is correct and points to the correct SQL LocalDB instance. Make sure that you are using the correct server name and database name in your connection string. This is what we usually do in queue at Triotech Systems,
- playermakerCopper Contributor
Could you please provide connection string of your application?
- Hugo O. OrnelasCopper Contributorplayermaker this is the connection string in "appsettings.json" before publishing:
///////
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-mywebapp-db_0_2023-d96111be-23db-4e9f-8e74-adafb6a9edaa;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
//////
- LanHuang
Microsoft
Hi Hugo O. Ornelas,
Thanks for posting your issue here.
However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang