How to unique identify each request in a ASP.NET Core 2 application (for logging)

ASP.NET Core also has HttpContext.TraceIdentifier which uniquely identifies the current request. It is generated for each incoming request by Kestrel, so isn’t suitable for correlating calls to one service from another, but is suitable for correlating logs for a single request together, or to correlating an error message that might be displayed to the user … Read more

How to determine if asp.net core has been installed on a windows server

You can search Microsoft .NET Core 1.1.1 – Windows Server Hosting registry key under HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Updates\.NET Core path like screenshot below. Also you can use PowerShell to determine the whether the key existed or not. $DotNETCoreUpdatesPath = “Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates\.NET Core” $DotNetCoreItems = Get-Item -ErrorAction Stop -Path $DotNETCoreUpdatesPath $NotInstalled = $True $DotNetCoreItems.GetSubKeyNames() | Where { $_ -Match “Microsoft … Read more

How to use WebApplicationFactory in .net6 (without speakable entry point)

Note that if you are trying to use xUnit and its IClassFixture<T> pattern, you will run into problems if you just use the InternalsVisibleTo approach. Specifically, you’ll get something like this: “Inconsistent accessibility: base class WebApplicationFactory<Program> is less accessible than class CustomWebApplicationFactory.” Of course you can solve this by making CustomWebApplicationFactory internal but it only … Read more

Migrating from OWIN to ASP.NET Core

Middleware is quite similar between Katana and Core but you use HttpContext instead of IOwinContext. Startup.cs is similar but there’s much more DI support. WebApi has been merged into MVC DelegatingHandler is gone, use middleware instead. HttpConfiguration has been split up into Routing and MvcOptions. Also https://devblogs.microsoft.com/aspnet/katana-asp-net-5-and-bridging-the-gap/

IdentityServer4 vs AspNet.Security.OpenIdConnect.Server vs OpenIddict

EDIT (01/28/2021): as part of the 3.0 update, AspNet.Security.OpenIdConnect.Server and OpenIddict were merged to form a single/unified codebase under the OpenIddict umbrella, which should offer the best of both worlds: you still have the same experience as before, but can now opt in for the degraded mode, giving advanced users the same lower-level approach as … Read more

What is the Signing Credential in IdentityServer4?

The Authorization Server will sign tokens with a key. Resource Server(s) should verify that the token’s integrity with a key. Together they form a (usually asymmetric, e.g. public/private) key (pair). By default IdentityServer will publish the public key for verifying tokens via the /.well-known/openid-configuration endpoint. For development scenarios, you typically want to skip the fuss … Read more

Are FromUri and FromQuery the same?

[FromQuery] attribute handles query parameters, i.e. key-value pairs coming after “?” in URI. [FromRoute] attribute handles route parameters coming before “?” in URI, i.e. path parameters. For example, if you configured route “orders/{id}”, then “id” is your route parameter, and if some actual request is like “orders/123?showHistory=true”, then “showHistory” is your query parameter. [FromUri] attribute … Read more

What the difference between [FromForm] and [FromBody] in Asp.Net Core

The FromForm attribute is for incoming data from a submitted form sent by the content type application/x-www-url-formencoded while the FromBody will parse the model the default way, which in most cases are sent by the content type application/json, from the request body. For security problem , you could use ValidateAntiForgeryToken Attribute for post method which … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)