gpt4 book ai didi

ajax - 如何将 Access-Control-Allow-Origin 添加到我在 VB 中创建的 ASMX Web 服务?

转载 作者:行者123 更新时间:2023-12-01 13:04:08 24 4
gpt4 key购买 nike

我有一个非常简单的 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 添加到响应 header ,以便使用 AJAX 的多个网站可以使用网络服务?

最佳答案

你试过在你的返回声明之前添加这个吗?:

Response.AddHeader("Access-Control-Allow-Origin","*")

关于ajax - 如何将 Access-Control-Allow-Origin 添加到我在 VB 中创建的 ASMX Web 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4107450/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com