How to enable cross domain Ajax call in Web API 2.0 ? (Part 10)

If we have created the Web API service and we are going to consume the service in same application then we will not get any exception. But the same service if we are going to call the other application, we will get the exception

No ‘Access-Control-Allow-Origin’ header is present on the requested resource

To fix this issue we have to make the cross domain enable ajax call in our service

It is very simple to implement this functionality

Step 1: Install the Microsoft.AspNet.WebApi.Cors plugin from Nuget package manager

Step 2: Go to WebApiConfig file and the code like this

Step 3: Now you can write the ajax call to consume the service as similar as previous post

How to consume web api using Jquery