Yesterday, according to the project team front-end development engineers, in the browser can not directly use AJAX access to the background interface to obtain data, according to his reflection, I consulted the relevant cross-domain solution:
One: Use Jsonp, but JSONP can only use GET request, completely do not meet my project situation, so continue to find, found ————
II: Webapi.core, citing articles (http://www.cnblogs.com/OpenCoder/p/6890703.html,http://www.cnblogs.com/OpenCoder/p/6893052.html)
The reasons for cross-domain and how to solve them are described in detail, and the following are some of the problems I encountered when I used them.
Use NuGet to download the package Microsoft.AspNet.WebApi.Cors 5.2.3.0, during use, This version is only compatible. net4.5 above version, because my project was built before 4.0, so the modified property is 4.5, after modification, a lot of DLL version and 4.5 does not correspond, so updated those DLL reference, here special note Microsoft.Net.Http This DLL, should with Cor s version of the same, these things have been modified after the compilation passed, but in the loading of the route thrown exception,
Exception is: Security Transparent Method "System.Web.Http.GlobalConfiguration.get_Configuration ()" Try ....
Find a lot of methods, involving a lot of knowledge, and finally adopted this post to solve the problem of cross-domain access (https://stackoverflow.com/questions/18476370/ HOW-DO-I-RESOLVE-THE-ERROR-ATTEMPT-BY-SECURITY-TRANSPARENT-METHOD-SYSTEM-WEB-H)
Use install-package ‘Microsoft.AspNet.WebApi.OData -pre
Cross-domain access using Cors background settings Webapi interface