Skip to content

Instantly share code, notes, and snippets.

@SimonDoy
Created May 12, 2016 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SimonDoy/2335c9cdfde258962df53482ca83b92e to your computer and use it in GitHub Desktop.
Save SimonDoy/2335c9cdfde258962df53482ca83b92e to your computer and use it in GitHub Desktop.
WebApiConfig with added CORS configuration
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Web.Cors;
using System.Web.Http.Cors;
namespace Itsp365.InvoiceFormApp.Api
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
var corsConfiguration = new EnableCorsAttribute("http://localhost:8080,http://127.0.0.1:8080,https://itsp365invoiceformappapitest.azurewebsites.net", "*", "*");
config.EnableCors(corsConfiguration);
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment