This is a migrated thread and some comments may be shown as answers.

Loading Nodes With Forms Authentication

2 Answers 77 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
digitall
Top achievements
Rank 1
digitall asked on 26 Apr 2012, 08:44 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Bozhidar
Telerik team
answered on 01 May 2012, 10:10 AM
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:

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

code-behind:
[WebMethod]
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";
        result.Add(childNode);
    }
    return result.ToArray();
}

 
Regards,
Bozhidar
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.
0
digitall
Top achievements
Rank 1
answered on 03 May 2012, 10:08 PM
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.
Tags
TreeView
Asked by
digitall
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
digitall
Top achievements
Rank 1
Share this question
or