ASP 中的访问控制允许来源 [英] Access-Control-Allow-Origin in ASP
问题描述
我有一个DOM"文件,它调用另一个域上的 ASP 文件(不是 .NET).如何在 ASP 中编写 Access-Control-Allow-Origin
?Access-Control-Allow-Origin
适用于PHP",但我找不到 ASP 的语法,我只能找到 ASP.NET 的语法
I have a "DOM" file that calls an ASP file (NOT .NET) on another domain.
How do I write the Access-Control-Allow-Origin
in ASP?
Access-Control-Allow-Origin
is for "PHP" but I cant find the syntax for ASP, I can only find it for ASP.NET
当我使用 Internet Explorer 时它工作正常,但在 Chrome 中它说
It works fine when I use Internet Explorer but in Chrome it says
请求的资源上不存在 Access-Control-Allow-Origin
标头.来源 'http://SOURCEDOMAIN' 因此不允许访问."
"No
Access-Control-Allow-Origin
header is present on the requested resource. Origin 'http://SOURCEDOMAIN' is therefore not allowed access."
推荐答案
将 HTTP 标头添加到 Classic ASP 中是一个简单的过程,Response
对象有一个专门用于此目的的方法,允许您将您想要的任何自定义标头添加到将在请求页面时发送到浏览器的 HTTP 标头中.
Adding HTTP headers into a Classic ASP is a trivial process, the Response
object has a method specifically for this purpose that allows you to add any custom header you want into the HTTP Headers that will be sent to the browser when the page is requested.
方法调用AddHeader()
这里是一个例子;
The method is called AddHeader()
here is an example;
<%
Call Response.AddHeader("Access-Control-Allow-Origin", "http://SOURCEDOMAIN")
%>
有用的链接
- W3 - 跨域资源共享
- 跨- 具有跨域资源共享的域 Ajax
- 使用 CORS
这篇关于ASP 中的访问控制允许来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!