一  只需为WebService添加一个属性[ScriptMethod(UseHttpGet = true)]

二 WebService
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;

/// <summary>
/// SimpleWebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class SimpleWebService : System.Web.Services.WebService
{
    public SimpleWebService()
    {

    }

    [WebMethod]
    [ScriptMethod(UseHttpGet = true)]
    public int Add(int a, int b)
    {
        return a + b;
    }
}

三  Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head ></div>
        </div>
    </form>
</body>
</html>

相关文章:

  • 2022-01-01
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2021-12-05
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2022-02-28
  • 2022-12-23
相关资源
相似解决方案