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
  1. Home
  2. Web Development
  3. ASP.NET
  4. ASP.NET Forms Authentication on subdirs

ASP.NET Forms Authentication on subdirs

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netsecurityquestion
3 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.
  • A Offline
    A Offline
    Andy M
    wrote on last edited by
    #1

    Hi, I am developing an ASP.NET application that uses forms authentication. However, it contains subdirectories, and they don't get authenticated somehow. I added a web.config and set the SignOn.aspx to the sign on page in the application's root directory. However, if I move to a page in one of the subdirectories it requires me to log in again. Once I log in successfully it keeps sending me back to my sign in page. Does anyone have any idea what I am doing wrong? Cheers, Andy

    S D 2 Replies Last reply
    0
    • A Andy M

      Hi, I am developing an ASP.NET application that uses forms authentication. However, it contains subdirectories, and they don't get authenticated somehow. I added a web.config and set the SignOn.aspx to the sign on page in the application's root directory. However, if I move to a page in one of the subdirectories it requires me to log in again. Once I log in successfully it keeps sending me back to my sign in page. Does anyone have any idea what I am doing wrong? Cheers, Andy

      S Offline
      S Offline
      Steven Campbell
      wrote on last edited by
      #2

      The way this works depends on whether the subdirectories are setup as IIS applications or not. If they are just directories, then the Authentication element of web.config must only appear in the main directory. The Authorization element of the config file can appear in each directory, so that you can specify permissions per directory. If each subdirectory is an IIS application, then each can have their own full web.config file. However, they still inherit some stuff from the parent directory. This is much harder to setup, although I think I saw an article somewhere on this site on how to do it. It may be that you can just remove the Authentication element from the web.config files in the subdirectories.


      my blog

      1 Reply Last reply
      0
      • A Andy M

        Hi, I am developing an ASP.NET application that uses forms authentication. However, it contains subdirectories, and they don't get authenticated somehow. I added a web.config and set the SignOn.aspx to the sign on page in the application's root directory. However, if I move to a page in one of the subdirectories it requires me to log in again. Once I log in successfully it keeps sending me back to my sign in page. Does anyone have any idea what I am doing wrong? Cheers, Andy

        D Offline
        D Offline
        Dave Wengier
        wrote on last edited by
        #3

        Assuming your subdirectories are seperate applications, the following should work: * Remove the authentication tag from the sub-directories' web.config. * Make sure the LoginUrl attribute of the authentication tag in the main web.config references a full path, not relative ("/signon.aspx" for example) * Add the following tag to the main web.config:

        <machineKey validationKey="AutoGenerate" decryptionKey="AutoGenerate" validation="SHA1" />

        --- Dave

        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