Tutorial by Examples

// Global.asax.cs calls this method at application start public static void Register(HttpConfiguration config) { // New code config.EnableCors(); } //Enabling CORS for controller after the above registration [EnableCors(origins: "http://example.com", headers: "*"...
public static void Register(HttpConfiguration config) { var corsAttr = new EnableCorsAttribute("http://example.com", "*", "*"); config.EnableCors(corsAttr); }
public void ConfigureServices(IServiceCollection services) { services.AddCors(o => o.AddPolicy("MyPolicy", builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); })); // ... } public void Configur...
public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddCors(); services.ConfigureCors(options => options.AddPolicy("AllowSpecific", p => p.WithOrigins("http://localhost:1233") ...
The following server-side configuration allows CORS request to work along with Windows Authentication (no anonymous must be enabled in IIS). web.config - allow unauthenticated (anonymous) preflight requests (OPTIONS) <system.web> <authentication mode="Windows" /> &l...
The following example shows how to properly construct both GET and POST requests against Web API 2 (CORS must be configured server-side, if sent from another domain): <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.js"></script> CORS with Wi...
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js"></script> CORS with Windows Authentication test (Angular) <script type="text/javascript"> var app = angular.module('myApp', []); app.c...

Page 1 of 1