Page load is triggered instead of web method

OK so my sites have been working fine so far, I'm not really sure what I changed. I have a jQuery AJAX call that sends a coupon code to the server and gets a number (which is a discount).

The web method no longer runs, instead the page_page of the page on which the web method is running is run. What for? What can I check? What can I do?

Here is my handler when the button is clicked

$('div#code_apply_btn').click(function() {
    $(this).html('PLEASE WAIT');


Here is the AJAX call

function getpromocode(){
    var pcode = $('input#input_circuitcode').val();
    var hid = parseInt($('input#ss_id_h').val());
        type: "POST",
        url: "register.aspx/get_promocode",
        data: '{"promo":"' + pcode + '", "uid":' + hid + '}',
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (msg.d != -1) {
            else {
                $('div#code_apply_btn').html('APPLY CODE');
        error: function (msg) {


Here's the web method

public static int get_promocode(string promo, int uid)
    return DAC.GetPromoCode(promo);


The web method never gets called, but the Page_load event fires and goes through everything and then gets 500 errors because it shouldn't be called and doesn't have all the data it needs.


All my other pages that use web methods are working fine. It's just this page.

Another strange behavior: in chrome, as soon as I start typing "register.aspx", Page_load is called. Again, all my other pages are fine, and it doesn't.


source to share

2 answers

I found the answer to my question:

Since I have VS2008, I can use .Net 3.5. My server, however, has .Net 4.0 or 2.0 for some reason I cannot select 3.5 as I would like. So every time I move my project I need to change the web.config file because the default 3.5 configuration is filled with a whole bunch of things 4.0 doesn't like.

So, I remembered that I freed the web.config to a barebone version that was still working in 3.5, which is the problem. I narrowed it down to these lines which I excluded from the version running locally on 3.5

    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, 
        System.Web.Extensions, Version=, Culture=neutral, 


I think the script module is what passes your jQuery requests to web methods, not the default page handler. There you go. But no obvious bugs or whatever, it just didn't work.



You must have EnablePageMethods = "true" in the ScriptManager on this page.



All Articles