Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have some folders in my asp.net project that each should has one web.config file but get Error: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level
and i have defined session state in each web .config.
at this part got error:
XML
<sessionState timeout="3" cookieless="AutoDetect"/>
    <authentication mode="Forms">
      <forms cookieless="AutoDetect" defaultUrl="~/Pages/Main_Page.aspx" loginUrl="Login.aspx" timeout="5" slidingExpiration="true" requireSSL="false" protection="All"/>
    </authentication>
    <authorization>
      <allow users="*"/>
    </authorization>
    <httpRuntime />
  </system.web>
  <location path="LogOut.aspx">
    <system.web>
      <httpRuntime requestValidationMode="2.0"/>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>


What I have tried:

i read some article but do not how do that!!!!!
Posted
Updated 12-Sep-19 8:12am
Comments
ZurdoDev 12-Sep-19 13:42pm    
Each folder needs to be defined as an application in IIS because you can only have one web.config per asp.net site.
OriginalGriff 12-Sep-19 14:16pm    
That turns out not to be the case: you can have multiple web.config files - one per folder - which override settings in the "higher up" versions. For example, a "Admin only" folder can have a web.config file which restricts access by "ordinary members", or teh login pages can be in a folder with an "open access" web.config, and so forth. It's pretty normal to have a web.config file per folder which specifies exactly who is allowed in.

Some elements of web.config are only allowed at "root" level however, and that's probably what his problem is.
MadMyche 12-Sep-19 16:05pm    
Never mind that Visual Studio 2010 would create 2 web.config files for a new MVC project; one for the actual application and the second was in the Views folder to block navigation to it (on the web)

1 solution

 
Share this answer
 
Comments
Member 14588785 14-Sep-19 17:14pm    
hi every body and thanks a lot.can we use session in global.asax file instead web.config.i mean not any change in web.config.just in global

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900