0

I'm implementing asp.net core 3.1 project and using sql server 2014. My app has got 4 controllers each of which has create, edit and delete actions. All of 3 controllers except one of them works fine whereas when I create or edit via the problematic controller, an error like the following is being shown to me:

An unhandled exception has occurred while executing the reques:

Exception: Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user 'NT AUTHORITY\LOCAL SERVICE'. at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool, SqlAuthenticationProviderManager sqlAuthProviderManager) ....

As I mentioned. all of the controllers except one of them has the above error for its actions. That controller is using 3 tables and one of them has one to many relationship with two others and those tables which are at many point have got acomputed column specification with the (isnull(CONVERT([int],(2)),(15))) formula. I appreciate if anyone can suggests me a solution.

Alexander Volok
  • 5,630
  • 3
  • 17
  • 33
MinaMRM
  • 343
  • 4
  • 16
  • I suggest to use SQL Profiler to capture the SQL statement and related exception that causes this issue. – Alexander Volok Oct 18 '20 at 09:25
  • I advice you to allow `NT AUTHORITY\LOCAL SERVICE` to server Role as `sysadmin`, you can have a reference for: https://stackoverflow.com/a/28721645/12884742 – LouraQ Oct 19 '20 at 08:25

1 Answers1

0

The problem could be in Sql Connection Strings and IIS Application Pool, what are these for your asp.net core application.

SqlException: Login failed for user 'DOMAIN\MACHINENAME$' for SQL Server with .NET Core 2.1

https://learn.microsoft.com/en-us/ef/core/miscellaneous/connection-strings https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1