Web.Config and subdirectory *location* security

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

  1. #1

    Default Web.Config and subdirectory *location* security

    I've read similar posts to this issue, and I am fairly certain this
    configuration should work. However, when I try to request any of the pages
    in the Admin subdirectory of my application root, I am given the following
    error:

    It is an error to use a section registered as
    allowDefinition='MachineToApplication' beyond application level. This error
    can be caused by a virtual directory not being configured as an application
    in IIS.

    It then has the line "<authentication mode="Forms">" highlighted as the line
    the error occurs at.

    Is this an IIS config issue, or do I need to create a configSections node in
    my web.config to facilitate this? If I need the configSections node added,
    an example would be very helpful. Thanks.


    <!-- Web.Config -->


    <configuration>
    <system.web>
    <authorization>
    <allow users="?" />
    </authorization>
    <compilation defaultLanguage="C#">
    <assemblies>
    <add assembly="MyAssembly" />
    </assemblies>
    </compilation>
    <customErrors mode="Off" />
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
    </system.web>

    <location path="Admin">
    <system.web>
    <authentication mode="Forms">
    <forms name=".MYAPPAUTH" loginUrl="login.aspx"
    protection="Encryption" timeout="20" />
    </authentication>
    <authorization>
    <deny users="?" />
    </authorization>
    <httpRuntime executionTimeout="90" maxRequestLength="512"
    useFullyQualifiedRedirectUrl="false" minFreeThreads="8"
    minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
    </system.web>
    </location>

    </configuration>


    Grant Harmeyer Guest

  2. Similar Questions and Discussions

    1. Create a subdirectory and change to subdirectory
      How can i create a subdirectory thru SDK in VB.NET? Like :- MD <NEWDIRNAME> CD <NEWDIRNAME> I dont know if my approach of searching is wrong,...
    2. BUG: Server.Execute ignores web.config <location> role permissions
      I have an intranet site that uses authentication mode="Windows" with identity impersonate="true". I recently implemented a site search feature that...
    3. How can the location roles be read from the web.config file?
      Security Experts, I have a config file such as this: <configuration> <system.web> <!--- other stuff goes here --> <authentication...
    4. Problem with web.config access-restricted subdirectory
      Hi, I have a problem with web.config unsuccessfully controlling access to a subdirectory. I'm using VS03 and IIS5.0 on NT2K. I have been able...
    5. web.config in subdirectory related query
      Hi all, I have read that you can have have multiple web.config files but some tags including <authentication> can only be present in the root...
  3. #2

    Default RE: Web.Config and subdirectory *location* security

    > Is this an IIS config issue, or do I need to create a configSections node in
    > my web.config to facilitate this? If I need the configSections node added,
    > an example would be very helpful. Thanks.
    The way to address this is to configure the admin sub dir as an application in IIS.

    The problem is that the authentication element can only be declared at the machine(for all apps hosted on a server), site, or application level. The documentation states: "Any attempt to declare it in a configuration file at the subdirectory or page level will result in a parser error message."
    See: [url]http://msdn.microsoft.com/library/en-us/cpgenref/html/gngrfauthenticationsection.asp[/url]

    Here's a good article for more info on setting up an app that uses windows and forms auth:
    [url]http://www.theserverside.net/articles/showarticle.tss?id=FormAuthentication[/url]

    "Grant Harmeyer" wrote:
    > I've read similar posts to this issue, and I am fairly certain this
    > configuration should work. However, when I try to request any of the pages
    > in the Admin subdirectory of my application root, I am given the following
    > error:
    >
    > It is an error to use a section registered as
    > allowDefinition='MachineToApplication' beyond application level. This error
    > can be caused by a virtual directory not being configured as an application
    > in IIS.
    >
    > It then has the line "<authentication mode="Forms">" highlighted as the line
    > the error occurs at.
    >
    >
    > <!-- Web.Config -->
    >
    >
    > <configuration>
    > <system.web>
    > <authorization>
    > <allow users="?" />
    > </authorization>
    > <compilation defaultLanguage="C#">
    > <assemblies>
    > <add assembly="MyAssembly" />
    > </assemblies>
    > </compilation>
    > <customErrors mode="Off" />
    > <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
    > </system.web>
    >
    > <location path="Admin">
    > <system.web>
    > <authentication mode="Forms">
    > <forms name=".MYAPPAUTH" loginUrl="login.aspx"
    > protection="Encryption" timeout="20" />
    > </authentication>
    > <authorization>
    > <deny users="?" />
    > </authorization>
    > <httpRuntime executionTimeout="90" maxRequestLength="512"
    > useFullyQualifiedRedirectUrl="false" minFreeThreads="8"
    > minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
    > </system.web>
    > </location>
    >
    > </configuration>
    >
    >
    >
    Chris Mohan Guest

  4. #3

    Default Re: Web.Config and subdirectory *location* security

    Thanks, I see that very clearly now and it makes sense. I went to
    [url]http://www.gotdotnet.com[/url] and downloaded the source code for the .Text blog
    application to analyze some of the tactics used in that application for
    authentication and also for some performance techniques.

    Thanks for the reply


    Grant



    "Chris Mohan" <ChrisMohan@discussions.microsoft.com> wrote in message
    news:FB25FC63-4379-47D7-91D4-663611E98F7F@microsoft.com...
    >
    > > Is this an IIS config issue, or do I need to create a configSections
    node in
    > > my web.config to facilitate this? If I need the configSections node
    added,
    > > an example would be very helpful. Thanks.
    >
    > The way to address this is to configure the admin sub dir as an
    application in IIS.
    >
    > The problem is that the authentication element can only be declared at the
    machine(for all apps hosted on a server), site, or application level. The
    documentation states: "Any attempt to declare it in a configuration file at
    the subdirectory or page level will result in a parser error message."
    > See:
    [url]http://msdn.microsoft.com/library/en-us/cpgenref/html/gngrfauthenticationsection.asp[/url]
    >
    > Here's a good article for more info on setting up an app that uses windows
    and forms auth:
    >
    [url]http://www.theserverside.net/articles/showarticle.tss?id=FormAuthentication[/url]
    >
    > "Grant Harmeyer" wrote:
    >
    > > I've read similar posts to this issue, and I am fairly certain this
    > > configuration should work. However, when I try to request any of the
    pages
    > > in the Admin subdirectory of my application root, I am given the
    following
    > > error:
    > >
    > > It is an error to use a section registered as
    > > allowDefinition='MachineToApplication' beyond application level. This
    error
    > > can be caused by a virtual directory not being configured as an
    application
    > > in IIS.
    > >
    > > It then has the line "<authentication mode="Forms">" highlighted as the
    line
    > > the error occurs at.
    > >
    >
    > >
    > > <!-- Web.Config -->
    > >
    > >
    > > <configuration>
    > > <system.web>
    > > <authorization>
    > > <allow users="?" />
    > > </authorization>
    > > <compilation defaultLanguage="C#">
    > > <assemblies>
    > > <add assembly="MyAssembly" />
    > > </assemblies>
    > > </compilation>
    > > <customErrors mode="Off" />
    > > <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
    > > </system.web>
    > >
    > > <location path="Admin">
    > > <system.web>
    > > <authentication mode="Forms">
    > > <forms name=".MYAPPAUTH" loginUrl="login.aspx"
    > > protection="Encryption" timeout="20" />
    > > </authentication>
    > > <authorization>
    > > <deny users="?" />
    > > </authorization>
    > > <httpRuntime executionTimeout="90" maxRequestLength="512"
    > > useFullyQualifiedRedirectUrl="false" minFreeThreads="8"
    > > minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
    > > </system.web>
    > > </location>
    > >
    > > </configuration>
    > >
    > >
    > >

    Grant Harmeyer 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