[英]The server method 'xxx' failed
I had this working and now it is not. 我有这个工作,现在却没有。 We have multiple developers working on the project but the code looks like when I had it working.
我们有多个开发人员在处理该项目,但是代码看起来像是在我工作时一样。 I saw a slight mention in another post that URL rewriting may cause an issue but it never went into if that was the problem or if there was a fix for that.
我在另一篇文章中提到过一点,URL重写可能会引起问题,但是如果这是问题所在或有针对此问题的修复程序,它就不会出现。 Sadly this is a Web Site (not Web App) but it WAS working.
遗憾的是,这是一个网站(不是Web App),但是可以正常工作。 Another possible issue is that we are using Ektron CMS.
另一个可能的问题是我们正在使用Ektron CMS。 Again, it was working with all of those variables, except the aliasing/rewriting of the URL, so this may be the issue.
同样,它使用了所有这些变量,但URL的别名/重写除外,因此可能是问题所在。
The javascript side sees the method in intellisense. javascript端在intellisense中看到了该方法。 I even have an alert showing me the method so it knows its there.
我什至有警报向我显示该方法,因此它知道该方法在那儿。 But I get the message: The server method 'LookupCourseItems' failed.
但是我收到消息:服务器方法“ LookupCourseItems”失败。
<script language="javascript" type="text/javascript">
function CourseLookup(ItemLookup, ResultID) {
alert('Attempting to look up: ' + ItemLookup);
var service = new AjaxDataServices.AjaxService();
service.LookupCourseItems(ItemLookup, onCourseLookupSuccess, onCourseLookupFailure, ResultID);
} // CourseLookup - Method
function onCourseLookupSuccess(result, userContext) {
var o = document.getElementById(userContext);
if (o != null) {
alert('Success!');
o.outerHTML = result;
} else {
alert('Unable to find: ' + userContext);
} // if we were able to find the element to fill
} // onCourseLookupSuccess - Method
function onCourseLookupFailure(result) {
alert(result.get_message());
alert("StackTrace: " + result.get_stackTrace());
alert("StatusCode: " + result.get_statusCode());
alert("ErrorObject: " + result.get_errorObject());
} // onCourseLookupFailure - Method
Here is the ScriptManager: 这是ScriptManager:
<asp:ScriptManager ID="ScriptManager" runat="server">
<Services>
<asp:ServiceReference Path="~/AjaxService.svc" />
</Services>
</asp:ScriptManager>
Here is the Service: 这是服务:
[ServiceContract(Namespace = "AjaxDataServices")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class AjaxService {
[OperationContract]
public string LookupCourseItems(string LookupPair) {
CourseRepository Repository = new CourseRepository(ConfigurationManager.ConnectionStrings["CAMS"].ConnectionString, 7);
string CourseID = "";
string SemesterName = "";
if (LookupPair.Contains(":")) {
string[] Parts = LookupPair.Split(new char[] { ':' },
StringSplitOptions.RemoveEmptyEntries);
CourseID = Parts[0];
SemesterName = Parts[1];
} else {
CourseID = LookupPair;
} // if the Semester was also given
Course Item = Repository.GetSingleCourseInformation(CourseID, SemesterName);
if (string.IsNullOrWhiteSpace(SemesterName))
return Item.ToHTML();
else
return Item.Semesters.Where(s => s.Name == SemesterName).SingleOrDefault().ToHTML();
} // LookupCourseItems - Method
When run, the initial "Attemping to look up: 1234" works. 运行时,初始的“尝试查找:1234”有效。 Then the onCourseLookupFailure method gets called and ruteurns the message in the title of this article.
然后,调用onCourseLookupFailure方法,并在本文标题中对消息进行处理。 Then the StackTrace is empty The StatusCode is 404 And the ErrorObject is null.
然后,StackTrace为空。StatusCode为404,而ErrorObject为null。
The 404 makes me think it can not find the service. 404让我觉得找不到服务。 This also seems logical since when I debug on the server side, it never gets to the Web Service.
这似乎也是合乎逻辑的,因为当我在服务器端进行调试时,它永远不会到达Web服务。
Any suggestions or thoughts? 有什么建议或想法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.