Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Restricting access to pages inside a folder

Restricting access to pages inside a folder

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Biju Sam
    wrote on last edited by
    #1

    Hi, i have an asp.net application which has pages in different folders like supervisors, managers etc. and each folder has n number of pages(aspx). it is finding difficulty for me to check the user rights for each page. so is it possible to restrict the user if he does not have the manager rights to all the pages in the manager folder? Please help. Biju S

    R N 2 Replies Last reply
    0
    • B Biju Sam

      Hi, i have an asp.net application which has pages in different folders like supervisors, managers etc. and each folder has n number of pages(aspx). it is finding difficulty for me to check the user rights for each page. so is it possible to restrict the user if he does not have the manager rights to all the pages in the manager folder? Please help. Biju S

      R Offline
      R Offline
      RepliCrux
      wrote on last edited by
      #2

      You must have a list of users, roles and UserRoles. You will have to use windows security to load the roles for the current user. Then ; protected void Page_Load(object sender, EventArgs e) CheckRole() { if(!IsPostBack) { //Do Something } public void CheckRole() { if (!Context.User.IsInRole("Manager")) { thow new Exception("Access Denied"); } } } You can usethe windows security using the following: using System.Security.Principal; and then IIdentity identity; String[] roles = {"manager","employee"}; GenericPrincipal g = new GenericPrincipal(identity, roles); You will have to fix the IIdentity part above.

      N 1 Reply Last reply
      0
      • B Biju Sam

        Hi, i have an asp.net application which has pages in different folders like supervisors, managers etc. and each folder has n number of pages(aspx). it is finding difficulty for me to check the user rights for each page. so is it possible to restrict the user if he does not have the manager rights to all the pages in the manager folder? Please help. Biju S

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        Use the web.config file to set security for the folders, similar to below only two letters away from being an asset

        1 Reply Last reply
        0
        • R RepliCrux

          You must have a list of users, roles and UserRoles. You will have to use windows security to load the roles for the current user. Then ; protected void Page_Load(object sender, EventArgs e) CheckRole() { if(!IsPostBack) { //Do Something } public void CheckRole() { if (!Context.User.IsInRole("Manager")) { thow new Exception("Access Denied"); } } } You can usethe windows security using the following: using System.Security.Principal; and then IIdentity identity; String[] roles = {"manager","employee"}; GenericPrincipal g = new GenericPrincipal(identity, roles); You will have to fix the IIdentity part above.

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          :rolleyes::wtf:


          only two letters away from being an asset

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups