这样比较复杂的验证还是用session方便一些吧,对应不同级别的登录赋不同的值,转到其他页面的时候先用一个判断。而且不收cookie的限制

解决方案 »

  1.   

    the current version of ASP.NET doesn't support authentication in non-virtual sub-directories, so you can try:1. make admin/shop/user all virtual directoriesor2. if your admin/shop/user are not virtual directories, authenticate the user in the root level, say, with login.aspx, then use role-based securities, so only role "Admins" can visit admin directory, role "Shop" can visit shop directory,....
    root-level web.config:
    <configuration>
       <system.web>
          <authentication mode="Forms">
             <forms name="401kApp" loginUrl="/login.aspx" />
          </authentication>
       </system.web>
    </configuration>the web.config in admin directory:<configuration>
       <system.web>
          <authorization>
             <allow roles="Admins" />
             <deny users="*" />
          </authorization>
       </system.web>
    </configuration>
    seeRole-based Security with Forms Authentication
    http://www.codeproject.com/aspnet/formsroleauth.asp
      

  2.   

    子目录验证在asp.net中还没有好的解决方案,如果在每个子目录下添加web.config还需要在iis中将所有的子目录设置为应用程序,很麻烦,并且经常出问题,我尝试过出现莫名巧妙的错误,
    建议自己写验证
    可以创建一个类将是否登陆,是否具有权限,以及角色的问题写成不同的方法,并在其中处理错误。在需要的地方引用就好,简单又方便,不算很烦!