From https://gist.github.com/michaelcox/1854201/raw/1f32a21549d37d9faa3386454a261090091843fc/AllowCrossSiteJson.cs