Losing user roles

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RGreatho
    New Member
    • Aug 2010
    • 3

    Losing user roles

    I am baffled, I am using a treeview to set the source of an iframe. The web page is being displayed correctly, but User.IsInRole(" roleName"), in the code behind, always returns false. The strange thing is User.Identity.N ame returns the correct user name. I have tried setting the target of the tree view nodes to "_blank" and to "_self" and still no luck. So, it doesn't appear that the problem is related to the iframe.

    Before the treeview was added, javascript was used to set the source for the iframe and User.IsInRole returned the correct values.

    Any ideas?
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Authentication cookies are used to associate a browser with a particular user in your system. IFrames are a little weird in that they act like "embedded windows". They may not share the same cookies and this could be the reason for why you have having problems.

    I'm not 100% sure how IFrames will work in this regard.

    If I were you I'd avoid IFrames. They have their applications but by the sounds of it you would benefit from converting your "Pages" into "Web User Controls" and use the TreeView to hide/show the user control selected.

    -Frinny

    Comment

    • RGreatho
      New Member
      • Aug 2010
      • 3

      #3
      Thanks! I still have the problem when I don't use the iframe, but display the page in a popup or in the same window. And I didn't have a problem when Javascript sets the source of the iframe. The treeview must be the culprit. Is there anything that a treeview does that would cause User.IsInRole() to always return false?

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Something weird is going on.
        Are you using any custom authentication features?

        -Frinny

        Comment

        • RGreatho
          New Member
          • Aug 2010
          • 3

          #5
          Just using forms authentication with a roles list retrieved from a SQL database. User.IsInRole() does work in the main page. I did a test which added the user roles to each url in the treeview, for example: ?roles=RW (for Read, Write) and the URLs are correct. They contain the user's roles retrieved from User.IsInRole() .

          Comment

          Working...