开发者

Page.User.Identity.IsAuthenticated returns object reference not set to instance of object

this works fine on my local site but as soon as i upload the site to my live server i get stem.开发者_开发问答NullReferenceException: Object reference not set to an instance of an object

on the first line of this:

if (!Page.User.Identity.IsAuthenticated)
{
    pnlSignIn.Visible = true;
    pnlSignOut.Visible = false;
}


You should use Request.IsAuthenticated instead of Page.User.Identity.IsAuthenticated.

Internally Request.IsAuthenticated will verify that the User and it's Identity are set (not null). You could do the same in your code, but why bother.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜