I have an ASMX
service located at Website\sitecore\shell\WebService\Validate.asmx
[System.Web.Script.Services.ScriptService]
public class Validate : System.Web.Services.WebService
{
[WebMethod(true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, XmlSerializeString = false)]
public PersonValidationResult ValidateNaturalPerson(string pk)
{
var valResult = PROC.ODSHelper.ValidateNaturalPerson(pk);
return valResult;
}
}
I'm trying to call the ValidateNaturalPerson method on textbox blur:
pkRegNum = $("#txtPerson").val();
var options = {
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
url: '/sitecore/shell/webservice/validate.asmx/ValidateNaturalPerson',
data: '{"pk":"'+pkRegNum+'"}',
success: function (response) {
HandleNaturalPersonResponse(response.d, source, pkRegNum);
},
error: function (a, b, c) {
alert('error');
}
};
$.ajax(options);
Pretty simple stuff. However on POST I keep getting HTTP 500 errors. When I check the response in Firebug it shows:
[ArgumentException: Unknown web method ValidateNaturalPerson/ValidateNaturalPerson.
Parameter name: methodName]
System.Web.Script.Services.RestHandler.CreateHandler(WebServiceData webServiceData, String methodName) +758655
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +89
Any ideas where the ValidateNaturalPerson/ValidateNaturalPerson comes from?
I assume it's the Sitecore messing with the request. I tried changing the URL in ajax beforeSend event, tried all kinds of ScriptMethod
/WebMethod
and POST
/GET
combinations but with no luck...
If you assume Sitecore is messing with your request you can tell Sitecore to ignore this request, so Sitecore won't intervene. You can do this by adding the page you've added to the "IgnoreUrlPrefix" setting in your web.config for your solution. Correct me if I'm wrong, but that should possibly do the trick.