Detailed explanation of methods for handling WebService cross-domain issues

php中世界最好的语言
Release: 2018-04-24 16:55:44
Original
2805 people have browsed it

This time I will bring you a detailed explanation of how to deal with WebService cross-domain issues. What are theprecautionsfor dealing with WebService cross-domain issues. The following is a practical case, let's take a look.

1. Background

Using the Ajax method inJqueryto create the WebServiceinterface in theasp.netdevelopment environmentcall

2. Problem

Cause analysis: Browser origin The impact of the policy (that is,JavaScriptorCookiecan only access content under the same domain);

3. Solution:

(1) JSONP: Only supports GET method

(2) CROS: Cross-domain resource sharing

The following is the CROS solution :

a. Add response header information to the WebService interface:

b. Add relevant information to the web.config file Configuration section information:

After applying solution a or b, the browser header information changes as follows:

In the end, the problem was solved better, but the support of each browser for this solution is different. The attached picture is as follows:

I believe you have mastered the method after reading the case in this article. For more exciting content, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Summary of three methods for Ajax to achieve cross-domain access

Perfect solution to ajax cross-domain problem

Summarized experience of using Ajax for 5 years

The above is the detailed content of Detailed explanation of methods for handling WebService cross-domain issues. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!