【发布时间】:2011-01-31 09:08:28
【问题描述】:
我可以使用以下 URL 直接将 webservie 调用到浏览器,它会返回我想要的所有内容:
http://localhost:64438/MySearchAutoComplete.asmx/GetCompletionList
当我像这样将它添加到 Default.aspx 页面的 autocompleteexetender 时:
<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
有什么想法吗?我注意到我需要附加进程来调试 web 服务,我可能也会做错什么?
编辑(事件查看器)
如果我转到我机器的事件查看器。我可以看到:
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 才能同时拥有两者。网络服务仍然有效(我可以直接触发它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...
【问题讨论】:
标签: c# asp.net asp.net-ajax web-services