.NET

How to Deploy ASP.NET Core Application to Windows with IIS

An ASP.NET Core application is hosted on Kestrel on both Windows and Linux. Kestrel is a web application server (just like Tomcat or NodeJS). It is included by default in ASP.NET Core project templates. Although ASP.NET Core application can run solely run on Kestrel, it is recommended to use it …

Sitecore

Implementing Dependency Injection in Sitecore

There are a few different ways to implement dependency injection in Sitecore. Once upon a time, the only way to implementing DI was to use third-party libraries like Simple Injector. Since Sitecore 8.2 release, Sitecore includes build in dependency injection based on Microsoft’s Dependency Injection for ASP.NET Core. We can …

.NET

Quickest Way to Enable CORS for ASP.NET Core Web API application

Browser security does not allow other domain to make AJAX requests.This is called same-origin policy which prevents malicious attack from other sites. When you need to allow other sites to make cross-origin requests, we can enable Cross-origin resource sharing (CORS). There is a pretty good documentation about enabling CORS for …

.NET

Unit Testing Entity Framework Database Update logic with NSubstitute

In the previous post (UnitTesting ASP.NET Web API by Mocking DbContext with NSubstitute), we explored how to create a unit test for getting data from database with Entity Framework by mocking DbContext and DbSet.  We are going to build upon the API we created previously and add PUT logic where …

.NET

Unit Testing ASP.NET Web API by Mocking DbContext with NSubstitute

In the previous post, we created a simpleWeb API in 5 minutes. Now, let’s refactor the code so that it is unit testable with xUnit. The API we build previously was sourcing the data from MySQL database through DbContext. This is an external dependency that we need to replace in …

.NET

Creating Web APIs using ASP.NET and MySQL in 5 minutes

Creating a web API that interact with a database with C# is quite easy thanks to ASP.NET and Entity Framework. Building API with ASP.NET is essentially creating a MVC application without View. If you learn how to create a website with ASP.NET, you can apply the skills directly to API …