Browsing Category: ASP.NET Core

Implement background tasks using IHostedService and access scoped service using IServiceScopeFactory

It is easy to implement Background tasks and scheduled work using IHostedService and the BackgroundService class. Sometimes it is required certain work to be offloaded when a Web API request is processed. That work could be accessing database records and update some information on some tables based on existing data. In this post, I’m going […]

How to remove the server header from ASP.NET Core 3.1

In this post, I will show how to remove the server header from ASP.NET Core 3.1. The fix is the same for other versions as well. Are you looking for more security features from the below list to implement in the ASP.NET Core application? content-security-policy x-content-type-options: nosniff x-download-options: noopen x-frame-options: Deny x-ua-compatible: IE=edge,chrome=1 x-xss-protection: 1; […]

Entity Framework Core dbcontextoptionsbuilder does not contain a definition for usesqlserver – Solved

Introduction In this post, I will show how to solve the error that shows “Entity Framework Core dbcontextoptionsbuilder does not contain a definition for UseSqlServer” with ASP.Net Core 3 and 3.1 framework. Overview We wanted to connect our ASP.NET Core application with MS SQL. To do this, we configure a connection in the startup class. […]