简体   繁体   English

服务器方法“ xxx”失败

[英]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? 有什么建议或想法吗?

I'd suggest using a tool called " Fiddler ", it's a HTTP debugging proxy that will enable you to see the HTTP requests from the client / server. 我建议使用一个名为“ Fiddler ”的工具,它是一个HTTP调试代理,可让您查看来自客户端/服务器的HTTP请求。

It may help you diagnose what is happening to your requests. 它可以帮助您诊断您的请求正在发生什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 调用服务器中心方法失败 - Failed invoking server hub method 未捕获的TypeError:对象# <YYY> 没有方法“ xxx” - Uncaught TypeError: Object #<YYY> has no method 'xxx' 发布到 Azure FHIR 服务器方法失败,身份验证失败 401 - Post to Azure FHIR Server method Fail to Authentication Failed 401 Javascript-调用ASP.NET WebService-服务器方法&#39;methodName&#39;失败 - Javascript - calling ASP.NET WebService - The server method 'methodName' failed 方法 post 无法加载资源服务器响应状态 404 - method post failed to load resource the server responded with a status 404 加载资源失败:服务器响应状态为405(不允许使用方法) - Failed to load resource: the server responded with a status of 405 (Method Not Allowed) 服务电子表格在访问 ID 为 xxx 的文档时失败 - Service Spreadsheets failed while accessing document with ID xxx 与猫鼬聚合时,在路径“ _id”的值“ xxx”的强制转换为ObjectId失败 - Cast to ObjectId failed for value “xxx” at path “_id” when aggregating with mongoose 在路径“ _id”处将“猫鼬”强制转换为ObjectId失败,值为“ xxx” - Mongoose Cast to ObjectId failed for value “xxx” at path “_id” 使用Mongoose时,错误'对象没有方法xxx' - Error 'Object has no method xxx ' while using Mongoose
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM