This article is a mirror article of machine translation, please click here to jump to the original article.

View: 21361|Reply: 1

[WebAPI] CORS setting WebApi cross-domain issue

[Copy link]
Posted on 7/12/2017 5:22:52 PM | | | |

CORS stands for Cross-Origin Resource Sharing, and Chinese is Cross-Origin Resource Sharing. It solves the cross-domain problem by adding corresponding identifiers to the HTTP request and response packets to tell the browser which domain names it can access

Use Nuget on the WebApiCORS project to search for "microsoft.aspnet.webapi.cors"



Then configure cross-domain in the WebApiConfig.cs folder under the App_Start folder
specify jQuery.support.cors = true; This sentence can solve the problem of IE8 and 9 supporting CORS

, this * sign is not safe. Because it means that as long as someone knows your request URL, any request can access your resource. This is quite dangerous. So we need to do some configuration to restrict access. For example, our more common practices are as follows:

Configuration method 1:

to the web.config configuration file








Configuration method 2:







Previous:How SQL Server imports oversized .sql files
Next:Video tutorial: In-depth analysis of common Java interview questions!
 Landlord| Posted on 7/12/2017 5:23:34 PM |
EnableCors specifies that multiple domain names can be accessed, usedComma separation



Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com