4
我试图在我的网站上实现视图跟踪Web服务。我使用的是JavaScript,因为我想从我的跟踪视图中排除任何搜索漫游器。问题是,当我尝试使用jQuery发布到我创建的Web服务时,出现“未知Web方法”错误。调用共享WebMethod时未知的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"
});
});
这是网络服务。
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。参数名称:方法名称
我已经做了几百次(看似),但我只是不能看到我失踪。我敢肯定,这是一个小...
我最终删除了这个Web服务,并开始一个新的,并且该Web服务工作。不过,我仍然对这个为什么不起作用感兴趣。 – 2010-07-01 14:57:40