Pat*_*ins 2 c# asp.net web-services asp.net-ajax
我可以使用以下URL直接将webservie调用到浏览器,它将返回我想要的所有内容:
http://localhost:64438/MySearchAutoComplete.asmx/GetCompletionList
Run Code Online (Sandbox Code Playgroud)
当我将它添加到autocompleteexetender到Default.aspx页面时,如下所示:
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1"
TargetControlID="TextBox1"
runat="server"
ServiceMethod="GetCompletionList"
ServicePath="http://localhost:64438/MySearchAutoComplete.asmx"
CompletionSetCount="12"
MinimumPrefixLength="1" />
Run Code Online (Sandbox Code Playgroud)
页面加载,我有一个文本框但每次在文本框中添加击键时我都有一个错误500.我在FireFox FireBug中看到了错误.
http://localhost:62702/ --->This is the webpage that load fine
Run Code Online (Sandbox Code Playgroud)
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)
Run Code Online (Sandbox Code Playgroud)
我还必须首先启动webservice项目,而不是停止它并启动webproject以便能够同时启动它们.web服务仍然可以工作(我可以直接启动http:// localhost:64438/MySearchAutoComplete.asmx?op = GetCompletionList)但是在网页上我仍然有错误500.
添加到webservice项目web.config:
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
Run Code Online (Sandbox Code Playgroud)
没有解决问题.
在Page_Load()中调用WebService中的相同方法非常有效:
string[] stuffs;
stuffs = proxy.GetCompletionList("1", 10);
MyList.DataSource = stuffs;
MyList.DataBind();
Run Code Online (Sandbox Code Playgroud)
但它不适用于AutoCompleteExtender ......
在Web服务器(即本地计算机)上的事件日志中,它应该提供更详细的错误消息.
把它添加到你的web.config我想
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
Run Code Online (Sandbox Code Playgroud)