This project is read-only.

Restricted access to custom pages

Topics: Themes
May 3, 2011 at 8:47 PM
Edited May 3, 2011 at 8:48 PM

I have added the following code to the site master page to create links to some custom pages with restricted access.  This seems to work okay, but as I move between pages I'm sometimes automatically logged off or encounter errors.  Is there a better method for this?

 <% if (Page.User.Identity.IsAuthenticated & Roles.IsUserInRole("administrators") == true)
                         { %>             
    <a href="">Custom Pages</a>
          <a href="./Test1.aspx">Test1 Text</a>
          <a href="./TEST2.aspx">Test2 Text</a>
                      <%} %>                  

Thanks Steve

May 4, 2011 at 1:29 PM

That code doesn't look like it should cause any errors.  It should run without error whether you are logged in or not.  The code also seems like a decent way to handle conditionally showing links.

If you're getting errors, I would investigate what those are by looking up information based on the error messages/details.  My guess is that they are unrelated to this markup you are showing here.

May 4, 2011 at 7:50 PM

I should have mentioned that I'm also using a second master page.  Could this be causing logg off issue?  See code below:   

Code on master page:

 protected void Page_Load(object sender, EventArgs e)
      sidepanel.Visible = false;
      content.Style["Width"] = "auto";

Code on page:
Protected Overrides Sub OnPreInit(ByVal e As EventArgs)

        Me.SueetieMasterBlogPage = "contact.master"
    End Sub