我有一个非常简单的ASMX页面......
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Script.Services
<WebService(Namespace:="http://localhost/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ScriptService()> _
Public Class JSWSGuessWeddingsByDay
Inherits System.Web.Services.WebService
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)> _
Public Function HowManyPeopleAreGettingMarriedToday() As Integer
Dim weddingCount As New Controller.Member.MemberDal
Return weddingCount.GuessWeddingsByDay(Nothing)
End Function
End Class
如何将Access-Control-Allow-Origin添加到响应标头中,以便多个网站可以使用AJAX使用Web服务?
答案 0 :(得分:4)
您是否尝试在返回声明之前添加此内容?:
Response.AddHeader("Access-Control-Allow-Origin","*")