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

asp.net 中Request.IsAuthenticated else 不执行 问题
C# code

if (Request.IsAuthenticated)
{
        FormsIdentity identity = (FormsIdentity)User.Identity;
        FormsAuthenticationTicket ticket = identity.Ticket;             
        string strUserID = User.Identity.Name;
        string strCompany = ticket.UserData.Split("|".ToCharArray())[0];
}
else
{
         lal_text.Value= "游客!";
}



C# code

web.config
<authentication mode="Forms">
    <forms name="webUserKey" loginUrl="login.aspx" defaultUrl="index.html" protection = "All" timeout="5"></forms>
</authentication>



else 里面不执行是什么问题。 
坐等高手。


------解决方案--------------------
先将 Request.IsAuthenticated 修改为 false,看看是否执行。

如果不执行,那么,这个判断本身都没有执行,或者执行了,但是lal_text.Value= "游客!";没有效果。

如果执行,看为什么还是IsAuthenticated。