jQuery ajax POST in Sitecore duplicates method name

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...

Answers


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.


Need Your Help

rails-opal and opal ujs on remote: true

ruby opalrb

I use rails-opal, opal-jquery gems, also require opal-ujs in application.js.rb, BUT on for example link_to "Foo", some_path, remote:true if I render e.g. remote_reply.js.rb layout:false with puts H...

Adding an invisible image watermark in C#?

c# .net image watermark invisible

I want to insert multiple invisible watermarks into my JPEG pictures through C# code. That means that I need a .NET library that does this work and not some external batch application.