Cross-domain access using Cors background settings Webapi interface

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.