Restricting Access to Pages by Roles

Last post 08-04-2009 11:19 PM by jcb871. 4 replies.

Sort Posts:

  • Restricting Access to Pages by Roles

    06-11-2009, 2:59 PM
    • Member
      15 point Member
    • redwoodbev
    • Member since 09-24-2008, 5:37 PM
    • Posts 89

    Hi.  My clubsite is online now, thanks to help from this forum.  I would like to be able to restrict access to events and maybe some other pages by roles.  Right now it looks like there are three roles, Administrators, Members(anyone logged in) and Guests (anyone not logged in).  I'm familiar with how the classified starterkit controls access by using roles in the sitemap file.  That doesn't seem to work with the clubsite.  Would someone point me in the right direction to limit access to pages based on user status or roles?

    Thanks, Bev

  • Re: Restricting Access to Pages by Roles

    06-11-2009, 3:26 PM
    Answer
    • All-Star
      21,117 point All-Star
    • bullpit
    • Member since 06-29-2006, 3:59 PM
    • Posts 4,665

    Are these pages in a separate folder or under the root folder directly? Sitemap trimming only hides the links to the pages in the menu, it won't prohibit access to the secured pages. You have to apply some sort of restriction separately. You can do that by <location> tag in web.config file like this: 

    <location path="SecuredFolder/SecuredPage.aspx">
        <system.web>
          <authorization>
            <allow roles="Administrators, Users"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
     
  • Re: Restricting Access to Pages by Roles

    06-11-2009, 4:21 PM
    • Member
      15 point Member
    • redwoodbev
    • Member since 09-24-2008, 5:37 PM
    • Posts 89

    Thank you so much.  That worked like a charm!  Bev

  • Re: Restricting Access to Pages by Roles

    06-11-2009, 4:24 PM
    • All-Star
      21,117 point All-Star
    • bullpit
    • Member since 06-29-2006, 3:59 PM
    • Posts 4,665

    You are welcome.

  • Re: Restricting Access to Pages by Roles

    08-04-2009, 11:19 PM
    • Member
      2 point Member
    • jcb871
    • Member since 08-04-2009, 11:11 PM
    • India
    • Posts 1

    Thank you a lot for that code... :)


    I need tyo show some message when the user is not authorized to view the page.

    Now it automatically redirects to login page.


    Thanks for help :)

    JB Loves All...
Page 1 of 1 (5 items)