我在/User目录下面放着与用户相关的页面,web.config里面设置:    <authentication mode="Forms">
        <forms path="/" name=".FormsAuthentication" loginUrl="Login.aspx" timeout="5256000" slidingExpiration="true">
        </forms>
    </authentication>
    <location path="user">
        <system.web>
            <authorization>
                <deny users="?" />
                <allow users="*" />
            </authorization>
        </system.web>
    </location>但是我发现一个奇怪的现象,大部分页面在登陆以后都可以正常访问,有些带有参数的页面,比如:Test.aspx?Id=555,在帐号[email protected]登陆的状态下可以正常访问,但是在帐号[email protected]登陆的状态下就不能访问,还是跳回到了登陆页面,而且再输入帐号[email protected]登陆还是不能成功。我将限制user登陆的web.config代码注释掉,在Test.aspx?Id=555中还设置了一段代码:FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value);
    FormsIdentity formsIdentity = new FormsIdentity(ticket);
    if (formsIdentity.IsAuthenticated)
        lblFormTest.Text = ticket.Name;在[email protected]帐号登陆的状态下,可以显示“[email protected]”,而在[email protected]帐号登陆的状态下,却显示:“An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. ”这个问题搞了一天了,真是郁闷。请各位帮忙。谢谢大家了。

解决方案 »

  1.   

    <allow users="*" />
    去掉试试
      

  2.   

    <system.web>
    <authentication mode="Forms">
            <forms path="/" name=".FormsAuthentication" loginUrl="Login.aspx" timeout="5256000" slidingExpiration="true">
            </forms>
        </authentication>
    <authorization>
    <allow users="*" />
    </authorization>
    </system.web>    <location path="user">
            <system.web>
                <authorization>
                    <deny users="?" />
                </authorization>
            </system.web>
        </location>