Access-Control-Allow-Origin Error
Problem: Trying to get jSON data from different domain/projects.
**Error:** XMLHttpRequest cannot load (myurl). Origin (myurl2) is not allowed by Access-Control-Allow-Origin.
Solution :
Add below code to global.asax file in your .NET project which you're trying to get data from...
protected void Application_BeginRequest(object sender, EventArgs e){
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
}
Written by Burak Kaya
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#.net
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#