开发者

How do I add Access-Control-Allow-Origin to an ASMX webservice I have created in VB?

开发者 https://www.devze.com 2023-01-23 11:35 出处:网络
I have a very simple ASMX page... Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols

I have a very simple ASMX page...

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


    <WebMeth开发者_开发问答od()> _
    <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

How do I add Access-Control-Allow-Origin to the response headers so that the webservice can be consumed by multiple websites using AJAX?


Have you tried adding this before your return statement?:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消