NLog configuration in appsettings.json instead of nlog.config in .NET Core

Yes, this is possible but has a minimum version requirement. You must be using NLog.Extensions.Logging >= 1.5.0. Note that for ASP.NET Core applications this will be installed as a dependency if you install NLog.Web.AspNetCore >= 4.8.2. You can then create an NLog section in appsettings.json and load it with the following code: var config = … Read more

Will CORS policy prevent resource access from non-browser requests?

However, does this prevent Http requests from a CURL, or other native applications/web-servers (ie. a request written and run via PHP) from successfully retrieving data from that resource? No, CORS config won’t prevent non-browser stuff from successfully retrieving your resources. The same-origin policy is enforced only by browsers. It’s not enforced by servers. (And CORS … Read more

HTTP Error 500.30 – ASP.NET Core app failed to start

There may be a few reasons behind the error which you can only identify by debugging. You can try to debug this error using the steps below: Navigate to the root directory of the application using CMD Run the application using the command dotnet run (yourApplicationName).dll If there are any errors, they should appear in … Read more

Read request body twice

If you’re using application/x-www-form-urlencoded or multipart/form-data, you can safely call context.Request.ReadFormAsync() multiple times as it returns a cached instance on subsequent calls. If you’re using a different content type, you’ll have to manually buffer the request and replace the request body by a rewindable stream like MemoryStream. Here’s how you could do using an inline … Read more