|
|
Posted on 2020-8-5 20:54:24
|
|
|
|

When a browser requests resources from a web page of one domain name to another domain name, the domain name, port, and protocol are any different, and they are cross-domain.
I have written a lot about cross-domain myself, as follows:
There are also specific descriptions of what cross-domain is:
The Cross-Domain Resource Sharing Standard adds a new set of HTTP header fields that allow the server to declare which origins have access to which resources through the browser. In addition, the specification requires that for HTTP request methods that may have side effects on server data (especially HTTP requests other than GET, or with some MIME types of POST requests), the browser must first initiate a preflight request using the OPTIONS method to know whether the cross-domain request is allowed by the server. The server confirms that it is allowed before making the actual HTTP request. In the return of a preflight request, the server can also inform the client if it needs to bring identity credentials (including cookies and HTTP authentication-related data).
HTTP Access Control (CORS)
The hyperlink login is visible.
Last weekend, on my blog introduction page, I returned the title of the article to the user in the form of calling the interface, because it was called to other second-level domain names, so there was a cross-domain problem, the interface was accessed through a POST request, and I forgot to set the OPTIONS request at the beginning, so the error was reported as follows:
The interface is written asp.net mvc controller, so you only need to add another OPTIONS request and allow cross-domain, the code is as follows:
access-control-allow-headers: *
access-control-allow-methods: GET, POST, PUT, DELETE
access-control-allow-origin: *
cache-control: private
content-length: 0
date: Wed, 05 Aug 2020 12:43:22 GMT
status: 200
(End)
|
Previous:SSIS Tutorial (7) SQL Server 2012 Executes SSIS JobsNext:Tencent, Hexun.com, Sina, Snowball, NetEase stock interface data
|