WebMethod is not called when the URL is being rewritten active

I know there are simulated messages, but I did not find any help in any of them.

My web methods work when I do not use URL rewriting, but as soon as I turn it on, stop working.

JQuery

        $.ajax({
            type: "POST",
            url: "index.aspx/SaveSetting",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                console.log(msg);
            }
        });

WITH#

    [WebMethod()]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
    public static string SaveSetting()
    {
        return "OK";
    }

When this is called, I get the full HTML address of my page and do not say "OK." I started the debugger and saw that when I call the web method, it runs Page_Load on my page, and not in the web method.

So, I got the corerct path, but the web method is not being called.

I am using C #, jQuery, ASP.NET 3.5.

Any help?

+6
source share
3 answers

You will need to use the full link to your web method.

If you look in firebug, you will see, for example:

http://localhost/test1/index.aspx/SaveSetting URL-, , , /test 1 /index.aspx

, , :

url:/index.aspx/SaveSetting

( URL-!)

, - asmx ?

+2

javascript:

PageMethods.set_path("/whatever/the/actual/path/is/index.aspx");

webmethod :

PageMethods.SaveSetting(console.log);

, .

0

, - . web.config -, IIS , -, :

<httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>

- - FRONT, -.

There may be other things in web.config that are needed. My huge (ha!), So who knows what else could affect this problem.

0
source

All Articles