开发者

How to tell asp.net membership login status control that user has signed in or IsAuthenticated

I have a login status control on a master page. If user is not signed it, it will show

"sign in"

otherwise it shows

"User Name - Sign Out"

The registration page has two views. One where users register, the other one where users has just registered (like a confirmation page).

The Register click is a server side click and goes through regular page flow to get to the event handler.

The problem is now the Confirmation view is displayed but the login status still shows "Sign in".

My custome开发者_如何学Cr wants to see "Sign Out" at this point. Even though FormsAuthentication.SetCookie has been called, but the call to IsAuthenticated is always resulting in false at any point in the Page flow events.

Is there a way to tell the login status that user is logged in and to rebind? Is there a way to extend the control to have such an event?


1.

FormsAuthentication.SetAuthCookie(user.UID, true); //IsAuthenticated changes to true

2.

FormsAuthentication.SignOut(); //IsAuthenticated changes to false

3.

(Web.config)

<authentication mode="Forms">
<forms loginUrl="~/Acount/Login" timeout="3000"></forms>

only this page can get user login information.

</authentication>

<authorization>

<deny users ="?" />

//It means any page if there is not login information, it will go to the loginUrl page automatically. </authorization>

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜