Loading Nodes With Forms Authentication

3 posts, 1 answers
  1. digitall
    digitall avatar
    169 posts
    Member since:
    Jun 2006

    Posted 26 Apr 2012 Link to this post

    I am currently using a RadTreeView as a system menu and trying to implement loading nodes on demand for better performance. The problem I am running into is whenever a call is made to either a page-based method or an asmx web service I can't determine the user making the call because HttpContext.Current.User.Identity.IsAuthenticated is always false, even though the user is actually logged in. My guess is this has to do with the way the request is being sent to the server since adding a section in the web.config blocking access to the page/service to unauthenticated users gets me an "authentication failed" error when expanding a node.

    What suggestions do you recommend for people in this situation? I'd prefer not to do server-side loads since those require so much extra data to be sent (viewstate, etc.).
  2. Answer
    Bozhidar avatar
    1191 posts

    Posted 01 May 2012 Link to this post

    Hello Scott,

    I tested your case, but everything worked fine on my end. I created a simple asp.net application with the default ASP authentication and membership mechanism (created automatically when you choose to create a new ASP.NET Application in Visual Studio), and used a page method to implement the load on demand. Could you try the same approach and see if the problem still occurs? 

    Below is the code for the treeview that I used:

    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <telerik:RadTreeView ID="RadTreeView1" runat="server">
                <telerik:RadTreeNode Text="Root" ExpandMode="WebService"></telerik:RadTreeNode>
            <WebServiceSettings Path="Default.aspx" Method="GetChildren" />    

    public static RadTreeNodeData[] GetChildren(RadTreeNodeData node, object context)
        List<RadTreeNodeData> result = new List<RadTreeNodeData>();
        if (HttpContext.Current.User.Identity.IsAuthenticated)
            RadTreeNodeData childNode = new RadTreeNodeData();
            childNode.ExpandMode = TreeNodeExpandMode.WebService;
            childNode.Text = "Text";
        return result.ToArray();

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. digitall
    digitall avatar
    169 posts
    Member since:
    Jun 2006

    Posted 03 May 2012 Link to this post

    I was trying to get it to work when using a standard ASMX service (not a page method with [WebMethod] attached) and the request didn't send the auth cookie so my service didn't think I was an authenticated user. I ended up using the ServerSideCallback which handled exactly what I needed to do though.
Back to Top