日期:2014-05-18  浏览次数:20392 次

根目录不需要身份验证,admin需要身份验证,如何配置?
我在admin下的web。config中
<authentication   mode= "Windows "   />  
       
        <authorization>
                <deny   users= "? "   />   <!--   拒绝匿名用户   -->
                              </authorization>

在根目录web。config中
  <authentication   mode= "Forms "   />  
        <Forms   name= "mycookiename "   loginUrl= "../login.aspx "   protection= "All "   timeout= "30 ">
          </Forms>


        <authorization>
                <allow   users= "* "   />   <!--   允许所有用户   -->
                                </authorization>


运行时显示下面的错误:
无法识别的配置节“Forms”

源错误:  


行   48:           -->
行   49:           <authentication   mode= "Forms "   />  
行   50:           <Forms   name= "mycookiename "   loginUrl= "../login.aspx "   protection= "All "   timeout= "30 ">
行   51:             </Forms>
行   52:  
 
请问如何改web。config
在loginclick()事件中又如何写呢?

------解决方案--------------------
在根目录的webconfig中加上
<location path= "Admin ">
<system.web>
<authorization>
<deny users= "? "/>
</authorization>
</system.web>
</location>

注意location 和根目录webconfig中原system.web 是同层的 别写错地方

其他的webconfig 就删了吧
------解决方案--------------------
web.config配置文件格式详细解读
请参阅:http://blog.leanrun.cn/index.php?load=read&id=50