0

I have a simple set up.

Jquery:

$.ajax({
  url: "/MyApp/MyHandler.ashx/MyMethod",
  success: function(result) {
    alert("sucess");
  },
  error: function() {
    alert('Error');
  }
});

and web method:

[System.Web.Services.WebMethod]
public static void MyMethod(){
  new AnotherClass(null).AnotherMethod(null, null); 
}

problem is success alert is called but break point is not hit inside MyMethod.

Rajesh
  • 24,354
  • 5
  • 48
  • 79
Imad
  • 7,126
  • 12
  • 55
  • 112

2 Answers2

0

I had the same issue and this is what I ended up having to do:

$.ajax({
   url: _url,
   data: '',
   dataType: 'json',
   contentType: 'application/json',
   type: 'POST',
   success: function(result) {
      alert("sucess");
   },
   error: function() {
      alert('Error');
   }
});

My first attempt left out the data, dataType and contentType; Only when I set contentType: 'application/json' with an empty string (data: '') did it end up working. What a headache - hope this helps someone else!

Adam
  • 1,546
  • 2
  • 18
  • 23
0

In my case, the issue was in RoutingConfig.So, sort that in App_Start folder, within RouteConfig,commented out the following line

//settings.AutoRedirectMode = RedirectMode.Permanent;

geet
  • 51
  • 2