More in this section

Forums / Developing with Sitefinity / JSON WebMethod page in Sitefinity

JSON WebMethod page in Sitefinity

2 posts, 0 answered
  1. Chris
    Chris avatar
    1 posts
    22 Feb 2009
    13 Apr 2009
    Link to this post
    I am trying to call a JSON webservice in a code-behind page in Sitefinity.  Here is the code in the aspx code-behind page...

    1 [WebMethod] 
    2     public static object States() 
    3     { 
    4         StateProvince[] states = new StateProvince[] { }; 
    5         ApplicationServiceClient proxy = null
    7         try 
    8         { 
    9             proxy = new ApplicationServiceClient(); 
    10             states = proxy.GetStateProvinces(); 
    11         } 
    12         finally 
    13         { 
    14             CloseServiceProxy(proxy); 
    15         } 
    16         return states; 
    17     } 

    I can call this web method just fine using Fiddler2 or via jquery ajax calls in the pages on my development web server.



    However, when I deploy to Sitefinity, I get the following exception...

    Server Error in '/FleetCardsUSA' Application.
    Unknown web method States.aspx.
    Parameter name: methodName

    I am wondering if there is a custom handler in Sitefinity that hijacks the request and post-pends the ".aspx" extension to my URL. 

    Anybody have any suggestions???

  2. Vlad
    Vlad avatar
    498 posts
    19 Jun 2017
    15 Apr 2009
    Link to this post
    Hi Chris,

    Yes we have this issue in Sitefinity 3.6. It is fixed in the upcoming service pack.
    A temporary workaround is discribed in this forum thread:

    The solution is for .svc extensions.
    In your case, you should use:
    using System;   
    using System.Collections.Generic;   
    using System.Web;   
    using Telerik.Cms.Web;   
    // Remove this class after upgrading to Sitefinity 3.6 SP1   
    public class CmsHttpModuleFix : CmsHttpModule   
        protected override void RewriteURL(string newURL, bool rebaseClientPath)   
            CmsHttpRequest cmsRequest = CmsHttpRequest.Current;   
            if (cmsRequest.IsPathChanged   
                && cmsRequest.ExtensionLower.Equals(UrlHelper.PageExtension)   
                && (cmsRequest.PathSegments.Length > 1)   
                && cmsRequest.PathSegments[cmsRequest.PathSegments.Length - 1].Contains(".aspx")   
            base.RewriteURL(newURL, rebaseClientPath);   

    We are sorry for the inconvenience.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered