VS2022, Dotnet Core 6 with Angular template publishing

Yitong Phou 21 Reputation points
2022-03-31T08:02:38.647+00:00

Please bare with me....

I have windows 11 installed on my computer. I have created a project (Dotnet core 6 with Angular and SQLEXPRESS) with authentication type = individual accounts. The project is for Dotnet 6 and x64. There is no changes after the project created except that I have to add 'defaultconnections' to the appsetting.json file.

It is compiled and works well in the development session. Then I released/published it to IIS real website. I found out that the app isn't working in IIS (It says localhost can't currently handle this request.
HTTP ERROR 500)
Note: I did install dot net core 6 run time on my machine.

Any suggestion?

If I created a project with no 'authentication' and no seqexpress and I release it to my IIS, the web is working fine until I added SQL express.

Is there any feature that I have missed?

Thanks

Internet Information Services
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,197 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,289 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Yitong Phou 21 Reputation points
    2022-04-01T17:53:33.13+00:00

    Category: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware
    EventId: 1
    SpanId: bc02c1561a355d75
    TraceId: 0bc3d4215ab66b43f8099c0011e8480e
    ParentId: 0000000000000000
    ConnectionId: 0HMGJJN6OJ3JM
    RequestId: 0HMGJJN6OJ3JM:00000002
    RequestPath: /_configuration/WebAngkorLar

    An unhandled exception has occurred while executing the request.

    Exception:
    System.InvalidOperationException: No service for type 'Duende.IdentityServer.Stores.ISigningCredentialStore' has been registered.
    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredServiceT
    at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.IdentityServerJwtBearerOptionsConfiguration.ResolveAuthorityAndKeysAsync(MessageReceivedContext messageReceivedContext)
    at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
    at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
    at Microsoft.AspNetCore.Authentication.AuthenticationHandler1.AuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme) at Microsoft.AspNetCore.Authentication.AuthenticationHandler1.AuthenticateAsync()
    at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)
    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

    0 comments No comments

  2. AgaveJoe 26,141 Reputation points
    2022-04-01T18:49:30.247+00:00

    I don't it is the issue. I used localDB and it still doesn't work. You should try to create the app and then release the code to IIS - IT DOESN'T WORK.:)

    The default connection string uses a trusted connection which is a windows integrated security. When you run the application from Visual Studio the host is running under your account which is most likely and administrator. When the application is hosted in IIS the application is running under the application pool account which does not have access to SQL or at least a login.

    Application Pool Identities

    If the login is the actual problem, I'm guessing, then you have to decide how you want SQL security to work. If you want to stick with a trusted connection then you should create a service account with limited access or you can use one of the existing service accounts like LocalService. In IIS Manager find the application pool for you web app and go to advanced settings... (right click). Find the "Identity" property and select Local Service or add your service account. Use Network Service if the DB is remote or a domain account with appropriate access.

    Next, in SQL server create the windows login. Replace Local Service with your service account or use Local Service

    CREATE LOGIN [NT AUTHORITY\Local Service] FROM WINDOWS;

    In SSMS open the security folder and double click NT AUTHORITY\Local Service. From here you can grant access read/write access to your database. In "User Mappings" select the DB and select dv_datareader and db_datawriter or whatever you need.

    If you go with a SQL account then you must create the login in SQL, grant read/write access, and update the connection string to include the user and password in the appsetting.json file rather than updating the application pool settings.


  3. Bruce (SqlWork.com) 56,771 Reputation points
    2022-04-14T16:56:55.38+00:00

    the error indicates you did not configure a valid credentials store. to encrypt cookies and tokens, asp.net core needs an encryption key (machine key on classic asp.net). this is generated at runtime and saved in the store for future use.

    the credentials store is supported via Data Protection Services and it requires a secrets store. on your dev box, the developers secrets store is used (an unencrypted filesystem store). now when you go to production, you need to use one that matches your requirements. if its a webfarm (more than one server) than you need to use a shared store.

    https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-6.0