I am trying to call via ajax a WebMethod hosted in a traditional ASP.Net WebForm code-behind page. Here is the code for the WebMethod:
[WebMethod]
public static object States()
{
StateProvince[] states = new StateProvince[] { };
ApplicationServiceClient proxy = null;
try
{
proxy = new ApplicationServiceClient();
states = proxy.GetStateProvinces();
}
finally
{
CloseServiceProxy(proxy);
}
return states;
}
The WebMethod works just fine in my stand-alone development environment or if deployed normally to IIS, but when I deploy the aspx page to Sitefinity, I get the following exception when it's called:
Server Error in '/' Application.
Unknown web method States.aspx.
Parameter name: methodName
I'm not sure if Sitefinity is hijacking the URL and post-pending the ".aspx" or what is going on here.
Here is the jquery call that is calling the web method:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Regions.aspx/States",
data: "{}",
success: function(data) {
// implementation omitted
},
error: function(xhr, msg) {
alert(xhr.responseText);
}
});
I can replicate the problem by posting the request manually using Fiddler.
Again, this works just fine everywhere except when deployed to Sitefinity. Anybody have any thoughts?