Created
February 18, 2016 09:15
-
-
Save john-lay/b71c906bd88132277324 to your computer and use it in GitHub Desktop.
Umbraco CORS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cannot get it working. Could ya help me?