Let’s enabling the CORS request in the ASP.NET Web API project, we need to add the CORS package from the Nuget using Nuget Package Manager i.e. - Microsoft.AspNet.WebApi.Cors Type the following command to install CORS Package – - Install-Package Microsoft.AspNet.WebApi.Cors We can configure CORS support for the Web API at three levels - 1. Enable CORS at the Global Level 2. Enable CORS at the Controller Level 3. Enable CORS at the Action Level Now open the file App_Start/WebApiConfig.cs and add the following code to the WebApiConfig.Register method. //WebApiConfig //Register Enable Cors Attribute in WebApiConfig file. using System . Web . Http ; using System . Web . Http . Cors ; namespace Demo . EnableCors { public static class WebApiConfig ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers