使用 jQueryAjax 更改大小写调用 WebMethod
Calling a WebMethod using jQueryAjax change casing
我有以下请求使用 ajax(简化):
<asp:TextBox ID="DealNumber" runat="server" Width="100px" ToolTip="Deal (aka OPG)">
</asp:TextBox>
<Ajax:AutoCompleteExtender
ID="AutoCompleteExtender2"
runat="server"
TargetControlID="DealNumber"
ServiceMethod="GetDealNumberList"
ServicePath="/ws/WebServices.asmx"/>
以及 /ws/WebServices.asmx(对不起我的 .VB):
<System.Web.Script.Services.ScriptMethod(UseHttpGet:=True)>
<System.Web.Services.WebMethod>
Public Function GetDealNumberList(prefixText As String, count As Integer, contextKey As String) As System.String()
return {"Test " & PrefixText & " " & ContextKey}
end function
现在,执行典型的 F12 网络跟踪,ajax 报告:
Invalid method name 'getdealnumberlist', method names are case sensitive. The method name 'GetWTNumberList' with the same name but different casing was found.
谁以及为什么更改外壳?如果我按预期修改我的 .asmx 作品。
不确定究竟是什么导致了这个问题,但我很久以前就遇到过这个问题,当时我还在使用网络表单页面和 AJAX 回调到 return 来自网络服务 (ASMX) 的东西。我通过将 MessageName
属性 和小写的方法名称放在 WebMethodAttribute
中解决了这个问题,就像这个例子:
<ScriptMethod(UseHttpGet:=True)>
<WebMethod(MessageName:="getdealnumberlist")>
Public Function GetDealNumberList(prefixText As String, count As Integer, contextKey As String) As String()
Return {"Test " & PrefixText & " " & ContextKey}
End Function
当直接测试网络服务方法时,有时也会出现此问题,例如通过输入 URL 比如 http://localhost:XXXX/path/to/webservicename.asmx/GetDealNumberList
.
在这个烦人的问题中,我找到了答案,而且很琐碎。
在Visual Studio中,当使用Option Compare Binary
时Option Compare Text
我的印象是只会影响代码生成。我错了。不确定为 Web 服务创建中间代码的方法是什么 and/or AJAX,但是,添加 Option Compare Text
修复了骆驼问题。
我个人认为这是一个(可存活的)bug。
我有以下请求使用 ajax(简化):
<asp:TextBox ID="DealNumber" runat="server" Width="100px" ToolTip="Deal (aka OPG)">
</asp:TextBox>
<Ajax:AutoCompleteExtender
ID="AutoCompleteExtender2"
runat="server"
TargetControlID="DealNumber"
ServiceMethod="GetDealNumberList"
ServicePath="/ws/WebServices.asmx"/>
以及 /ws/WebServices.asmx(对不起我的 .VB):
<System.Web.Script.Services.ScriptMethod(UseHttpGet:=True)>
<System.Web.Services.WebMethod>
Public Function GetDealNumberList(prefixText As String, count As Integer, contextKey As String) As System.String()
return {"Test " & PrefixText & " " & ContextKey}
end function
现在,执行典型的 F12 网络跟踪,ajax 报告:
Invalid method name 'getdealnumberlist', method names are case sensitive. The method name 'GetWTNumberList' with the same name but different casing was found.
谁以及为什么更改外壳?如果我按预期修改我的 .asmx 作品。
不确定究竟是什么导致了这个问题,但我很久以前就遇到过这个问题,当时我还在使用网络表单页面和 AJAX 回调到 return 来自网络服务 (ASMX) 的东西。我通过将 MessageName
属性 和小写的方法名称放在 WebMethodAttribute
中解决了这个问题,就像这个例子:
<ScriptMethod(UseHttpGet:=True)>
<WebMethod(MessageName:="getdealnumberlist")>
Public Function GetDealNumberList(prefixText As String, count As Integer, contextKey As String) As String()
Return {"Test " & PrefixText & " " & ContextKey}
End Function
当直接测试网络服务方法时,有时也会出现此问题,例如通过输入 URL 比如 http://localhost:XXXX/path/to/webservicename.asmx/GetDealNumberList
.
在这个烦人的问题中,我找到了答案,而且很琐碎。
在Visual Studio中,当使用Option Compare Binary
时Option Compare Text
我的印象是只会影响代码生成。我错了。不确定为 Web 服务创建中间代码的方法是什么 and/or AJAX,但是,添加 Option Compare Text
修复了骆驼问题。
我个人认为这是一个(可存活的)bug。