locked
Restricting Access to Pages by Roles RRS feed

  • Question

  • User1988740161 posted

    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

    Thursday, June 11, 2009 2:59 PM

Answers

  • User1485238302 posted

    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>
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 11, 2009 3:26 PM

All replies

  • User1485238302 posted

    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>
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 11, 2009 3:26 PM
  • User1988740161 posted

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

    Thursday, June 11, 2009 4:21 PM
  • User1485238302 posted

    You are welcome.

    Thursday, June 11, 2009 4:24 PM
  • User-534295916 posted

    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 :)

    Tuesday, August 4, 2009 11:19 PM