I am trying to use a jquery autocomplete with an ajax call to a webservice method the call works fine on localhost but when published to the dev server it fails everytime and using google chrome to debug i get the following error:
System.InvalidOperationException: Missing parameter: sLookUP. at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection) at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
I am using ASP.NET3.5 with IIS 7.5 where as the dev machine is IIS 6 with ASP.NET 2.0
My ajax call is as follows:
$("#<%=txtSearch.ClientID %>").autocomplete({
source: function(request, response) {
$.ajax({
url: "http://ift.tt/1GGf9sg",
data: "{ 'sLookUP': '" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function(data) {
My webmethod in Address.asmx :
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public String[] ShowAddress(string sLookUP)
{
List<string> lstAddresses = new List<string>();
DataTable dtAddresses;
Address Addr = new Address();
dtAddresses = Addr.GetLookupAddresses(sLookUP);
foreach (DataRow row in dtAddresses.Rows)
{
lstAddresses.Add(string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}-{8}", row["OrderAddress_name"], row["OrderAddress_id"], row["OrderAddress_1"], row["OrderAddress_2"], row["OrderAddress_town"], row["OrderAddress_county"], row["OrderAddress_postcode"], row["OrderAddress_fulladdress"],row["OrderAddress_ClusterID"]));
}
return lstAddresses.ToArray();
}
web.config settings (there's been suggestions on other questions these should help:
<webServices>
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="Documentation"/>
</protocols>
</webServices>
<system.webServer>
<handlers>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers>
</system.webServer>
Any suggestion welcome I've tried so many things but as it works on my machine i'm thinking its an iis/web.config setting I've missed or written incorrectly because the dev machine has a different setup. Thanks
Aucun commentaire:
Enregistrer un commentaire