+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / JSON WebMethod not working in Sitefinity

JSON WebMethod not working in Sitefinity

1 posts, 0 answered
  1. yuki
    yuki avatar
    0 posts
    Registered:
    25 Jul 2016
    25 Jul
    Link to this post

    Hi there,

     

    I've sitefinity hosted in asphostportal.com. then 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?

     

     

     

     

     

1 posts, 0 answered