Forms Authentication on Subdirectories of App

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Forms Authentication on Subdirectories of App

    I would like to have a directory that is Forms authenticated so that all
    ASP.NET resources contained within the directory require a logged on user.
    Per spec, I have to accomplish this through the use of the <location />
    element in the web.config file. I have written the code that authenticates
    the user against a DB and that works fine with the login page. However, when
    I attempt to type in a URL for a file in that directory (that is not the
    login page) and I have NOT logged in, the page is still served. So, the
    authentication is not being checked. I haven't done anything with forms
    authentication before, and I have it set up nearly the same as it is set up
    in the Programming ASP.NET book by Dino Esposito, except of course for the
    Web.Config file. I also don't see anywhere in Dino's book that the
    Authentication is checked after the initial login.

    The whole thing wouldn't be much of a problem if this was it's own app with
    it's own Web.Config, but per spec... not that way.

    Web.Config
    -----------------------------------------
    <location path="main/">
    <system.web>
    <authentication mode="Forms">
    <forms loginURL="login.aspx"
    name="MaintenanceLogin"
    protection="Encryption"
    timeout="20"
    path="/" />
    </authentication>
    <authorization>
    <deny users="?" />
    </authorization>
    <compilation defaultLanguage="C#">
    <assemblies>
    <add assembly="GnMaintain" />
    </assemblies>
    </compilation>
    <customErrors mode="Off" />
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
    <httpRuntime executionTimeout="90" maxRequestLength="4096"
    useFullyQualifiedRedirectUrl="false" minFreeThreads="8"
    minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
    </system.web>
    </location>


    Grant Harmeyer Guest

  2. Similar Questions and Discussions

    1. Accessing htm files without authentication (forms authentication)
      I have application with forms authentication. All works fine. When user opens .aspx file gets login form, login and then get the .aspx page. But...
    2. ASP.Net Forms authentication with basic authentication popup
      Relatively new to ASP.Net but have a strange problem. My site uses forms authentication for a large administration section however after the user...
    3. Forms authentication then redirection to a secure web with NT authentication?
      Hi, I want to allow access to particular secured intranet web sites. These intranet are stored in sharepoint (2003 version) Actually I've...
    4. Authentication ticket, cookieless, forms authentication?
      Hi. I want to use Forms Authentication, cookieless. The issue is setting the Authentication Ticket without using cookies (!) That is, the...
    5. Forms authentication with Windows authentication
      Hi, I have an ASP.NET web site that uses IIS Basic Authentication and accesses an OLAP Server at various stages. The OLAP Server authentication...
  3. #2

    Default Re: Forms Authentication on Subdirectories of App

    I think the location path should be just path="main".
    You can find a more extensive explanation of this topic here:
    [url]http://www.theserverside.net/articles/printfriendly.aspx?l=FormAuthentication[/url]

    Hernan L.


    "Grant Harmeyer" <gn_harmeyer@hotmail.com> wrote in message
    news:OKHCJ%23C8DHA.2676@TK2MSFTNGP10.phx.gbl...
    > I would like to have a directory that is Forms authenticated so that all
    > ASP.NET resources contained within the directory require a logged on user.
    > Per spec, I have to accomplish this through the use of the <location />
    > element in the web.config file. I have written the code that authenticates
    > the user against a DB and that works fine with the login page. However,
    when
    > I attempt to type in a URL for a file in that directory (that is not the
    > login page) and I have NOT logged in, the page is still served. So, the
    > authentication is not being checked. I haven't done anything with forms
    > authentication before, and I have it set up nearly the same as it is set
    up
    > in the Programming ASP.NET book by Dino Esposito, except of course for the
    > Web.Config file. I also don't see anywhere in Dino's book that the
    > Authentication is checked after the initial login.
    >
    > The whole thing wouldn't be much of a problem if this was it's own app
    with
    > it's own Web.Config, but per spec... not that way.
    >
    > Web.Config
    > -----------------------------------------
    > <location path="main/">
    > <system.web>
    > <authentication mode="Forms">
    > <forms loginURL="login.aspx"
    > name="MaintenanceLogin"
    > protection="Encryption"
    > timeout="20"
    > path="/" />
    > </authentication>
    > <authorization>
    > <deny users="?" />
    > </authorization>
    > <compilation defaultLanguage="C#">
    > <assemblies>
    > <add assembly="GnMaintain" />
    > </assemblies>
    > </compilation>
    > <customErrors mode="Off" />
    > <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
    > <httpRuntime executionTimeout="90" maxRequestLength="4096"
    > useFullyQualifiedRedirectUrl="false" minFreeThreads="8"
    > minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
    > </system.web>
    > </location>
    >
    >

    Hernan de Lahitte Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139