我在根目录web.config里设置如下
<authentication mode="Forms">
<forms name=".aspnet" loginUrl="User/Login.aspx" defaultUrl="index.aspx" timeout="60" path="/">
</forms>
</authentication>
这个是用于用户没登陆就条到用户的登陆页面的我有个目录是admin 我这个目录下的web.config里该怎么样设置实现如下功能?我直接把下面的放进去要出错
<authentication mode="Forms">
<forms name=".aspnet" loginUrl="Admin/Login.aspx" defaultUrl="~/admin/index.aspx" timeout="60" path="/">
</forms>
</authentication>想实现用于管理员没登陆就条到管理员的登陆页面的请问该怎么样实现?

解决方案 »

  1.   

    用sitemap+membership 来做 可以实现 
    http://hi.baidu.com/meilixueshan/blog/item/9cc7024ca3030fffd72afc37.html
      

  2.   

    找到C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG目录下的machine.config文件(中间有个为你.net的版本号),打开
    将<session name="autoentication"节点下的allowDefinition属性设为"Everywhere"
      

  3.   

    admin里的web.config里写个
    <authorization>
       <deny users="?"/>
    </authorization>
      

  4.   

    在配置文件的</system.web>后面加
    <location path="path"> <!--path可以某个目录也可以是具体的文件--> 
      <system.web> 
        <authorization>
        ……
        </authorization> 
        <authentication mode="Forms">
        ……
        </authentication> 
      </system.web> 
    </location>
      

  5.   


    我这样
    <location path="~/admin">
    <!--path可以某个目录也可以是具体的文件-->
    <system.web>
    <authentication mode="Forms">
    <forms name=".aspnet" loginUrl="Admin/Login.aspx" defaultUrl="~/admin/index.aspx" timeout="60" path="/"> 
    </forms>
    </authentication>
    </system.web>
    </location>
    还是不行了`访问admin目录里的aspx还是条到了用户登陆页面```
      

  6.   

    是放在根目录的web.config里的,访问admin目录里的网页没有进行判断
      

  7.   

    <authorization>
    <allow roles="ADMIN" />
    <deny users="*"/>
    </authorization>
    加了这个的
      

  8.   

    这不是IIS根目录的问题,而是应用程序根目录的问题。你要要在IIS里面创建/admin为独立的应用程序,然后/和/admin就是两个独立的应用程序了,互不影响。当然,/admin也就不算是/的一般子目录了。