我正在尝试在我的网站上实现一个视图跟踪web服务。我使用JavaScript是因为我想从跟踪视图中排除任何搜索机器人。问题是,当我尝试使用jQuery发布到我创建的web服务时,遇到了一个“未知web方法”错误。
$(document).ready(function() {
$.ajax({
type: "POST",
url: '<%=ResolveUrl("~/WS/ItemViewTrackingService.asmx/TrackItemView") %>',
data: "{'itemType': 'thread', 'itemId':<%=mThread.ThreadID %>}",
contentType: "application/json; charset=utf-8"
});
});
这是web服务。
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class ItemViewTrackingService
Inherits System.Web.Services.WebService
<WebMethod(EnableSession:=True)> _
Public Shared Sub TrackItemView(ByVal itemType As String, ByVal itemId As Int32)
If itemType.Equals("column", StringComparison.OrdinalIgnoreCase) Then
Services.ViewTrackingService.TrackColumnView(itemId)
ElseIf itemType.Equals("thread", StringComparison.OrdinalIgnoreCase) Then
Services.ViewTrackingService.TrackThreadView(itemId)
End If
End Sub
End Class
错误是ASP.NET错误:未知的web方法TrackItemView。参数名称:methodName