代码之家  ›  专栏  ›  技术社区  ›  Patrick Desjardins

ASP.NET AJAX Web服务和内部错误500

  •  2
  • Patrick Desjardins  · 技术社区  · 14 年前

    我可以使用以下url直接将webservice调用到浏览器,它将返回我想要的所有内容:

    http://localhost:64438/MySearchAutoComplete.asmx/GetCompletionList
    

    当我将其添加到autocompleteexetender的default.aspx页面时,如下所示:

    <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" 
                      TargetControlID="TextBox1" 
                      runat="server" 
                      ServiceMethod="GetCompletionList" 
                      ServicePath="http://localhost:64438/MySearchAutoComplete.asmx" 
                      CompletionSetCount="12"
                      MinimumPrefixLength="1" />
    

    页面加载时,我有一个文本框,但每次在文本框中添加击键时都会出现错误500。我在firefox firebug中看到了错误。

    http://localhost:62702/   --->This is the webpage that load fine 
    

    alt text http://clip2net.com/clip/m12122/1269451120-clip-2kb.png -->这是错误

    有什么想法吗?我注意到我需要附加进程来调试webservice,我可能也会对它做一些错误的事情?

    编辑(事件查看器)

    如果我转到我机器的事件查看器。我可以看到:

    Exception information: 
        Exception type: InvalidOperationException 
        Exception message: Request format is unrecognized for URL unexpectedly ending in '/GetCompletionList'. 
    
    
        Thread information: 
        Thread ID: 8 
        Thread account name: MTL\daok 
        Is impersonating: False 
        Stack trace:    at     System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
       at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
       at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
       at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    

    我还必须首先启动webservice项目,而不是停止它并启动webproject才能同时拥有这两个项目。webservice仍然有效(我可以直接启动它 http://localhost:64438/MySearchAutoComplete.asmx?op=GetCompletionList )但在网页上我仍然有错误500。

    编辑2(web.config)

    添加到webservice项目web.config:

      <webServices>
        <protocols>
          <add   name="HttpGet"/>
          <add   name="HttpPost"/>
        </protocols>
      </webServices>
    

    没有解决问题。

    编辑3(直接呼叫)

    在page_load()中调用来自webservice的相同方法非常有效:

         string[] stuffs;
         stuffs = proxy.GetCompletionList("1", 10);
         MyList.DataSource = stuffs;
         MyList.DataBind();
    

    但它不能与autocompleteextender一起工作…

    2 回复  |  直到 6 年前
        1
  •  6
  •   Martin Smith    14 年前

    在Web服务器(即您的本地计算机)上的事件日志中,它应该给出更详细的错误消息。

    我想把这个添加到web.config

    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    
        2
  •  0
  •   PopGlintz    6 年前

    只要确保你取消注释 [System.Web.Script.Services.ScriptService] 就在下面 WebServiceBinding 在web服务类页面的顶部。

    这应该能解决问题。 如果仍然存在,请检查 SitePath 通过在URL前面包含“~”,确保它正确地植根于Web服务的位置,如下所示:

    SitePath="~/Webservice.asmx"