0

ASP.Net Core Web API Versioning

In this tutorial, we are going to see how to support versioning for ASP.Net Core Web API endpoints. Versioning helps API owners to roll out enhanced functionalities to different customers on a time to time basis without breaking the old versions of endpoints. In previous versions of ASP.Net, we used to create a custom IHttpControllerSelector through which we will route the request to appropriate controller version based on custom header or URL pattern. In ASP.Net Core, we will use aspnet-api-versioning middleware (created by Chris Martinez).

0

Demystify Publish folder of an ASP.Net Core MVC Application

In this tutorial we are going to demystify the contents of Publish folder of an ASP.Net Core MVC application. To host an ASP.Net Core Application, we publish it using dotnet publish command of Dotnet CLI. Publish folder is created as an output of dotnet publish command and it contains all the necessary dependencies along with project artifacts for successful project hosting.

0

Publish an ASP.Net Core 1 Application to IIS

In this tutorial, we are going to see how to publish an ASP.Net Core 1 Application to IIS. Unlike older versions of ASP.Net, ASP.Net Core 1 applications are not dependent on IIS for hosting. In fact ASP.Net Core 1 applications are console applications and run in their own Kestrel Web Server. But if we need to have more functionalities which IIS provides by default (or through extensions), then we can use IIS as reverse proxy which will forward requests to Kestrel.

0

Print a Webpage with CSS in ASP.Net MVC

In this tutorial we are going to see how to print a webpage which is developed in ASP.Net MVC. The usual problems which we face in printing a webpage is with the rendering of CSS on print version. Also different browsers behave differently while printing pages with background styles and images. We are going to use traditional JavaScript’s window.print() to trigger print functionality.

0

In-Memory and Distributed Caching in ASP.Net Core MVC Application

Caching helps in improving performance of an application by replicating the data (otherwise which has to be fetched from database or any other source). ASP.Net Core supports both in-memory and distributed caching. In-memory caching holds the copy of data in local server’s memory, where as distributed cache maintains cache in a centralized location which is accessible by servers in cluster. In this tutorial we are going to see how to implement both in-memory and distributed caching in ASP.Net Core MVC application.

0

JumpStart # 45 – Redis Cache based Session State in ASP.Net Core MVC Application

In this Jumpstart, we are going to see how to use Redis Distributed Cache Server as Session store for an ASP.Net Core Application. There are multiple advantages in having a distributed cache storage (in this case it is Redis Cache) acting as Session store. Sessions can be shared across multiple applications and also between multiple servers in a cluster. Redis is also capable of supporting different data types and it is faster than SQL Server (because of its in-memory nature). Redis also supports cluster for scaling and persistence to disk (data will not be lost on server restarts).

0

JumpStart # 44 – SQL Server based Session State in ASP.Net Core MVC Application

In this Jumpstart, we are going to see how to use SQL Server as Session store for an ASP.Net Core Application. There are multiple advantages in having a distributed cache storage (in this case it is SQL Server) acting as Session store. Sessions can be shared across multiple applications and also between multiple servers in a cluster. There are also some disadvantages around performance (in-memory is faster than SQL Server based session store) and operational overheads of maintaining additional SQL Server database.

0

Using Session in ASP.Net Core MVC Application

In this tutorial, we are going to see how to configure an ASP.Net Core MVC Application to use Session state. In previous versions of ASP.Net, session management is straight forward by using HttpSessionState. But in ASP.Net Core MVC application it is not straight forward, we have to add and configure ISession Service along with an IDistributedCache implementation. In ASP.Net Core, ISession exposes new API to support saving and retrieving objects from Session state.

0

JumpStart # 43 – Understanding Program and Startup classes in ASP.Net Core Application

Program and Startup classes are breaking changes in ASP.Net 5 (although they are existed in unified Startup class, in ASP.Net Core they are diverged into separate classes) which are used to start the application and support application’s HTTP pipeline. In previous versions of ASP.Net we have Global.asax which exposes different events at application life cycle level. In this jumpstart, we are going to see what is the relevance of both classes in ASP.Net Core Application.

0

Deploy .Net Core Console Application based Azure WebJob using PowerShell

In this tutorial, We are going to see how to deploy an Azure WebJob which is based out of an .Net Core Console Application using PowerShell. At this point of time there is no built-in support in Visual Studio to deploy .Net Core based application as an Azure WebJob. We can either deploy the WebJob directly at Azure Portal (which is straight forward) or by using PowerShell. We are going to use combination of PowerShell and Azure Cmdlets to deploy the WebJob.

0

Azure WebJob with .Net Core Console Application

In this tutorial we are going to see how to use .Net Core Console Application as an Azure WebJob. .Net Core Console application is different from traditional .Net framework Console Application in generating the project outputs. Traditional .Net framework Console App generates executable as project output, but .Net Core Console App will generate DLL (library). We have to do little extra work to make .Net Core Console Application work as Azure WebJob.

0

Create a simple Azure WebJob with parameters

In this tutorial we are going to see how to create a simple Azure WebJob using a C# console application with parameters. Azure WebJobs are used to run scripts or programs (typically long running) as background processes on Azure Web Apps. WebJobs can be ran in three different ways – Manually triggered, Trigger on a Schedule and continuously trigger. WebJobs are capable of executing different scripts(for example cmd, bat, exe, js, jar, ps1 etc.,).

0

JumpStart # 42 – Download file in ASP.Net MVC

In this jumpstart, we are going to see how to download a file from server to client browser in ASP.Net MVC using a RouteHandler . A RouteHandler will be created to handle all the requests made to a particular URL with specific route data (part of URL itself) to identify the file requested and will return a particular HttpHandler for the request. HttpHandler is going to find the file on the server, set it into the Response of HttpContext and finally send the response back to the client (typically a browser, but it can be anything).

0

JumpStart # 41 – Browser Link in ASP.Net Core MVC Application

Browser Link is a feature of Visual Studio (from 2013) which will help in refreshing web application in different browsers at once in debug mode. Browser Link uses SignalR to establish a communication channel between Visual Studio and browser. When browser link is in use, Visual Studio acts as SignalR Server and browsers will act as clients and any new changes will be propagated to browsers just with a button click in VS.

0

Send SMS in ASP.Net Core 1 Web API Application using Twilio

In this shot tutorial, we are going to see how to send an SMS in ASP.Net Core 1 Application using Twilio SMS Provider. Twilio is a cloud infrastructure based communications company which allows software developers to make and receive phone calls and send and receive text messages using its web service APIs. Twilio offers pay-as-you-go pricing model which makes easy to get the required services at right time. Additionally Twilio offers volume pricing for high volume requirements. Unfortunately Twilio doesn’t support .Net Core development at this point of time, but we can still use its Cloud based API to get the required functionality.

0

Send email in ASP.Net Core 1 Web API Application using SendGrid

In this short tutorial, we are going to see how to send an email in ASP.Net Core 1 application using SendGrid email provider. SendGrid is a cloud-based email provider for businesses which will take away the burden of complexity in maintaining custom email infrastructure and configuration. SendGrid got different subscription plans for businesses (customization is available for high volume) which includes a free plan of 12,000 emails per month. Fortunately SendGrid supports .Net Core development through its nuget package and it is very easy to integrate.

0

CORS Support in ASP.Net Core Web API Application

Cross Origin Resource Sharing (CORS) is one of the important standard which will allow applications on different domains to interact with each other. Without CORS, applications are prevented by browser to make cross origin AJAX requests (cross origin means different applications hosted on different domains). Enabling CORS is helpful in scenarios where frontend UI and backend API are hosted on different domains. Fortunately in ASP.Net Core configuring CORS is a very easy task.

0

Appsettings.json configuration in ASP.Net Core Web API

ASP.Net Core provides appsettings.json file through which we can maintain all the custom configuration required for the successful execution of application. This is a breaking change compared to previous versions of ASP.Net where web.config is primarily used to hold configuration. Appsettings.json is light weight configuration file where all settings are stored in json format and just like web.config we can have have different configuration files for different environments (do not mistake me this is nothing related to transformations, but rather cascading). Accessing this configuration data can be done through Options pattern and ASP.Net Core provides a default middleware to achieve this functionality. In this tutorial, we will see how to access configuration in appsettings.json file and also how to maintain different config files for different environments (staging, production etc.).

0

Exception Handling in ASP.Net Core Web API Application

Exception handling in the key feature in making an application robust and secure. Handling exceptions at different levels is always a tricky task. In previous versions of ASP.Net, we have multiple ways (Exception filter, Global.asax, OnException at Controller etc.,) to achieve exception handling. Fortunately ASP.Net Core made developers life easy by making global exception handling available through middleware. If default middleware doesn’t meet a project’s requirement, one can always create a custom middleware to handle exceptions.

0

Dependency Injection in ASP.Net Core Application

Dependency Injection is a design pattern in which dependencies are injected into a class at runtime. This software pattern ensures the system is loosely coupled and have high code reusability. So typically we have an interface which defines the signature of the whole contract, and then we have different implementations (not necessarily many, but at least one) of the same interface. Now we have Web Application which is dependent on this interface. Then using Dependency injection we can inject the right implementation (there should be mapping of interface and implementation either in configuration file or at Startup.cs) of the interface at runtime (or whenever the web application is in need of).

0

CRUD Operations with ASP.Net Core Web API

In this tutorial, we are going to see how to create an ASP.Net Core Web API project. We will develop a simple CRUD (Create Read Update Delete) operations API for Student object. Finally we will test the API using Postman tool (a tool to build, test and document APIs). ASP.Net Core framework follows a single and unified approach for building both MVC and Web API applications (because it share the common code base and the same HTTP pipeline). The plain pipeline (which ASP.Net Core provides) gives more control to developer to innovate through his own middleware’s (in fact MVC/Web API is a middleware too) and also a flexibility to include his own choice of 3rd party middleware’s to achieve the functionality.