为了防止用户绕过登录页面进入其他网页,除了在每张页面都用session进行判断外,还有没有其他更简单的方法,比如在Session_Start中进行一次判断就可以了。 

解决方案 »

  1.   

    个人认为不可以
    一直用session
      

  2.   

    用cookie;
    在WEB.CONFIG文件中配置
    <authentication mode="Forms"/> 
    <forms name="cookie" loginUrl=""……>
    ……
    </authentication>
      

  3.   

    采用Form认证,然后修改Web.Config
            <authorization>
                 <deny users="*"/>
            </authorization>
    添加认证Handle,具体的忘记是Web.Config中的哪个Section了,可以查查帮助
    <configuration>
       <configSections>
          <sectionGroup name="system.net">
             <section name="authenticationModules"
                type="System.Net.Configuration.NetAuthenticationModuleHandler, 
                System, Version=1.0.3300.0, Culture=neutral, 
                PublicKeyToken=b77a5c561934e089"/>                               
             <section name="webRequestModules" 
                type="System.Net.Configuration.WebRequestModuleHandler, 
                System, Version=1.0.3300.0, Culture=neutral,
                PublicKeyToken=b77a5c561934e089"/>
           </sectionGroup>       <sectionGroup name="system.web">
              <section name="authorization" 
                 type="System.Web.Configuration.AuthorizationConfigHandler, 
                 System.Web, Version=1.0.3300.0, Culture=neutral, 
                 PublicKeyToken=b03f5f7f11d50a3a"/>            
              <section name="sessionState" 
                 type="System.Web.SessionState.SessionStateSectionHandler,
                 System.Web, Version=1.0.3300.0, Culture=neutral,
                 PublicKeyToken=b03f5f7f11d50a3a"
                 allowDefinition="MachineToApplication"/>        
           </sectionGroup>
        </configSections>   <system.net>
          <! — Net Class Settings would go here. -->
       </system.net>
       <system.web>
            <authorization>
                <allow users="*"/> <!-- Allow all users -->
                <!-- Allow or deny specific users.
                allow users="[comma separated list of users]"
                      roles="[comma separated list of roles]"/>
                <deny users="[comma separated list of users]"
                      roles="[comma separated list of roles]"/>
                -->
            </authorization>
            <sessionState 
                sqlConnectionString="data source=localhost;
                   Integrated Security=SSPI;
                   Initial Catalog=northwind"
                cookieless="false" 
                timeout="10"/>
       </system.web>
    </configuration>