Cors.ConfigProfiles is here!

less than 1 minute read

After working on my previous blog post, where I had to use the EnableCorsAttribute, I thought: “Why can’t I make profiles for this in the web.config file, like you can for the OutputCacheAttribute?”

Enter my brand new, shiny NuGet package: Cors.ConfigProfiles! It enables you to use the EnableCorsAttribute just like you normally would, but you can also just give it one string parameter which then matches a profile inside the web.config file. So, for example, if you put this attribute on an API controller:

public class MyApiController : ApiController {
    // ...

Then you can configure that profile in web.config like so:

<?xml version="1.0" encoding="utf-8"?>
    <section name="cors" type="Cors.ConfigProfiles.Configuration.CorsSection, Cors.ConfigProfiles, Version=, Culture=neutral, PublicKeyToken=253caed373cef676" requirePermission="false" />
      <add name="MyApiProfile" 

And if you want to contribute or just inspect what I did (no unicorns involved though), the code is available on GitHub.