jQuery AJAX调用C#WebService事项及配置.pdfVIP

  • 3
  • 0
  • 约1.99万字
  • 约 16页
  • 2026-02-05 发布于北京
  • 举报

使用jQueryAJAX调用C#WebService需要注意的几个事项

:1、web.config里需要配置2个地方httpHandlersremoveverb*path

*.asmx/addverb*path*.asmxvalidatefalsetype

System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions,

Version=1.0.61025.0,Cultureneutral,PublicKeyToken=31bf3856ad364e35//

httpHandlers在system.web/system.web之间加入webServicesprotocols

addnameHttpPost/addnameHttpGet//protocols/webServices

2.正确地编写WebService的代码

///summary///UserValidate的说明////summary[

WebService(Namespace=)][

WebServiceBinding(ConformsTo=WsiProfi.BasicProfile1_1)][

System.ComponentModel.ToolboxItem(false)]//若要允许使用ASP.NETAJAX从脚

本中调用此Web服务,请取消对下行的注释。[

System.Web.Script.Services.ScriptService]publicclassUserValidate:

System.Web.Services.WebService{DFHon.Content.Common.rootPublicrp=

newDFHon.Content.Common.rootPublic();[WebMethod][

ScriptMethod(ResponseFormatResponseFormat.Json)]publicstring

ValidateUserLogState(){stringresult=;Http

HttpContext.Current.Request.s[DHFonMenberInfo];if(!=null)

{

jqueryajax调用webservice(C#)要注意的几个事项:

1、web.config里需要配置2个地方

httpHandlers

removeverb=*path=*.asmx/

addverb=*path=*.asmxvalidate=false

type=System.Web.Script.Services.ScriptHandlerFactory,System.Web.Extensions,

Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35/

/httpHandlers

在system.web/system.web之间加入

webServices

protocols

addname=HttpPost/

addname=HttpGet/

/protocols

/webServices

2.正确地编写webserivce的代码

///summary

///UserValidate的说明

////summary

[WebService(Namespace=)]

[WebServiceBinding(ConformsTo=WsiProfi.BasicProfile1_1)]

[System.ComponentModel.ToolboxItem(false)]

//若要允许使用ASP.NETAJAX从中调用此Web服务,请取消对下行的注释。

[System.Web.Script.Services.ScriptService]

publicclassUserValidate:Sy

文档评论(0)

1亿VIP精品文档

相关文档