It is an error to use a section allowDefinition='MachineToApplicat

Discussion in 'ASP .Net Security' started by Neal Miller, Sep 19, 2006.

  1. Neal Miller

    Neal Miller Guest

    Hi, I'm getting 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."

    I have researched this issue a lot, and can say that:
    1) The Application's Path is "C:\Inetpub\wwwroot\Appname".
    2) This path is defined as a Virtual Directory in IIS.
    3) The Application has a subfolder named "Administration".
    4) The "Administration" subfolder is also defined as a Virtual Directory.
    5) The web.config file in the Appname folder contains the following text:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <!-- xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"-->
    <system.web>
    <compilation defaultLanguage="c#" debug="true"/>
    <xhtmlConformance mode="Legacy" />
    <customErrors mode="Off"/>
    <authentication mode="Forms">
    <forms timeout="2000">
    <credentials passwordFormat="Clear">
    <user name="username1" password="pwd1"/>
    </credentials>
    </forms>
    </authentication>
    <authorization>
    <deny users="?"/>
    </authorization>
    <trace enabled="false" requestLimit="10" pageOutput="true"
    traceMode="SortByTime" localOnly="false"/>
    <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
    sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    cookieless="false" timeout="2000"/>
    <globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
    </system.web>
    </configuration>

    6) The web.config file in the Administration subfolder contains the
    following text:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <!-- xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"-->
    <system.web>
    <compilation defaultLanguage="c#" debug="true"/>
    <xhtmlConformance mode="Legacy" />
    <customErrors mode="Off"/>
    <authorization>
    <deny users="?"/>
    </authorization>
    <trace enabled="false" requestLimit="10" pageOutput="true"
    traceMode="SortByTime" localOnly="false"/>
    <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
    sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    cookieless="false" timeout="2000"/>
    </system.web>
    </configuration>

    VS.NET 2005 comes up with the above error on the SessionState line here on
    this subfolder's web.config file. If I remove the sessionState section on
    this subfolder's web.config file and re-build, then many pre-compile errors
    are detected in VS 2005, including many "Error 2 The name 'Global' does not
    exist in the current
    context C:\Inetpub\wwwroot\Appname\Administration\ReceiveSystem.aspx.cs 23
    ", and this error: Warning 1 Invalid search path 'C:\PROGRAM\PCOBOL32'
    specified in 'LIB environment variable' -- 'The system cannot find the path
    specified. '

    If I leave the subfolder's web.config sessionState parameter in it, I only
    get the "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." error.

    I am aware that sessionState is only supposed to be defined in the top-most
    level, but if I do so, I would appreciate any assistance in overcoming the
    other errors that I mentioned above.

    Thanks in advance.
    Neal Miller, Sep 19, 2006
    #1
    1. Advertising

  2. Neal Miller

    Neal Miller Guest

    FYI: I resolved the outstanding issue(s).

    There were a number of problems in this application, which I converted from
    1.1.

    1) Multiple web.config files were not necessary. The orig app had them. I
    removed all but the web.config in the main folder, and the
    "MachineToApplication" error went away.

    2) The original programmer coded database access logic in a Global.asax.cs
    code-behind file. This does not work very well in 2.0. I moved that common
    logic to a new class, then deleted the Global.asax and Global.asax.cs files,
    since no other custom logic existed there, converted all code that reference
    the former Global. logic to the new class, and that resolved many of the
    outstanding issues.

    3) I modified all SqlCommand.Parameter.Add logic to use the new 2.0 format
    to eliminate many of the deprecated command warnings.

    The application now compiles and runs successfully with no errors or warnings.



    "Neal Miller" wrote:

    > Hi, I'm getting 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."
    >
    > I have researched this issue a lot, and can say that:
    > 1) The Application's Path is "C:\Inetpub\wwwroot\Appname".
    > 2) This path is defined as a Virtual Directory in IIS.
    > 3) The Application has a subfolder named "Administration".
    > 4) The "Administration" subfolder is also defined as a Virtual Directory.
    > 5) The web.config file in the Appname folder contains the following text:
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <configuration>
    > <!-- xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"-->
    > <system.web>
    > <compilation defaultLanguage="c#" debug="true"/>
    > <xhtmlConformance mode="Legacy" />
    > <customErrors mode="Off"/>
    > <authentication mode="Forms">
    > <forms timeout="2000">
    > <credentials passwordFormat="Clear">
    > <user name="username1" password="pwd1"/>
    > </credentials>
    > </forms>
    > </authentication>
    > <authorization>
    > <deny users="?"/>
    > </authorization>
    > <trace enabled="false" requestLimit="10" pageOutput="true"
    > traceMode="SortByTime" localOnly="false"/>
    > <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
    > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    > cookieless="false" timeout="2000"/>
    > <globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
    > </system.web>
    > </configuration>
    >
    > 6) The web.config file in the Administration subfolder contains the
    > following text:
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <configuration>
    > <!-- xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"-->
    > <system.web>
    > <compilation defaultLanguage="c#" debug="true"/>
    > <xhtmlConformance mode="Legacy" />
    > <customErrors mode="Off"/>
    > <authorization>
    > <deny users="?"/>
    > </authorization>
    > <trace enabled="false" requestLimit="10" pageOutput="true"
    > traceMode="SortByTime" localOnly="false"/>
    > <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
    > sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    > cookieless="false" timeout="2000"/>
    > </system.web>
    > </configuration>
    >
    > VS.NET 2005 comes up with the above error on the SessionState line here on
    > this subfolder's web.config file. If I remove the sessionState section on
    > this subfolder's web.config file and re-build, then many pre-compile errors
    > are detected in VS 2005, including many "Error 2 The name 'Global' does not
    > exist in the current
    > context C:\Inetpub\wwwroot\Appname\Administration\ReceiveSystem.aspx.cs 23
    > ", and this error: Warning 1 Invalid search path 'C:\PROGRAM\PCOBOL32'
    > specified in 'LIB environment variable' -- 'The system cannot find the path
    > specified. '
    >
    > If I leave the subfolder's web.config sessionState parameter in it, I only
    > get the "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." error.
    >
    > I am aware that sessionState is only supposed to be defined in the top-most
    > level, but if I do so, I would appreciate any assistance in overcoming the
    > other errors that I mentioned above.
    >
    > Thanks in advance.
    Neal Miller, Sep 20, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex D.
    Replies:
    1
    Views:
    9,517
    Alex D.
    May 20, 2005
  2. ruffeo
    Replies:
    0
    Views:
    318
    ruffeo
    Feb 7, 2007
  3. jc
    Replies:
    1
    Views:
    791
    Michael Nemtsev [MVP]
    Oct 28, 2008
  4. AAaron123
    Replies:
    4
    Views:
    1,478
    AAaron123
    Jan 21, 2009
  5. Dominick Baier [DevelopMentor]
    Replies:
    5
    Views:
    810
    Dominick Baier [DevelopMentor]
    Jul 5, 2006
Loading...

Share This Page