Skip to content

Instantly share code, notes, and snippets.

@john-lay
Created February 18, 2016 09:15
Show Gist options
  • Save john-lay/b71c906bd88132277324 to your computer and use it in GitHub Desktop.
Save john-lay/b71c906bd88132277324 to your computer and use it in GitHub Desktop.
Umbraco CORS
// Don't forget to update Global.asax to point to this class!!
namespace UmbracoCms._7._3._4.App_Start
{
using System;
using System.Web.Http;
using System.Web.Http.Cors;
/// <summary>
///
/// </summary>
public class MyCmsApplication : Umbraco.Web.UmbracoApplication
{
/// <summary>
/// Called when [application starting].
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected override void OnApplicationStarting(object sender, EventArgs e)
{
base.OnApplicationStarting(sender, e);
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}
/// <summary>
///
/// </summary>
public static class WebApiConfig
{
/// <summary>
/// Registers the specified configuration.
/// </summary>
/// <param name="config">The configuration.</param>
public static void Register(HttpConfiguration config)
{
var corsAttr = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(corsAttr);
}
}
}
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
<add name="Access-Control-Allow-Methods" value="GET, PUT, POST, DELETE, HEAD" />
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
</customHeaders>
</httpProtocol>
@jhemesonmotta
Copy link

Cannot get it working. Could ya help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment