I am working on login/signup module(FYI no rolls/membership just a simple login form),data flow is from sql server for both registeration and login,and code is currently working fine.
I am trying to use signin/signout functionality in my code. I have already created a login form and the user is able to login and after successful login, user is redirected to default_page.aspx.
my r&d code upto this is as:
<td width="122" align="right"><asp:LinkButton ID="LinkButton1" runat="server"
onclick="LinkButton1_Click">Sign Out</asp:LinkButton></td>
cs page:
protected void LinkButton1_Click(object sender, EventArgs e)
{
//After click Log out we need to delete all session values
Session.RemoveAll();
Response.Redirect("userlogin.aspx");
}
from above code u can see I have put only a linkbutton and if user click on above link button user got sign out and redirected to loginpage(here userlogin.aspx). But now if I am trying to change(see below aspx and .cs) as signin|signout i am getting error as:‘System.Security.Principal.IPrincipal’ does not contain a definition for ‘IsAuthenticated’ and no extension method ‘IsAuthenticated’ accepting a first argument of type ‘System.Security.Principal.IPrincipal’ could be found (are you missing a using directive or an assembly reference?)
aspx page:
<td width="122" align="right"><asp:LinkButton ID="LinkButtonSignInOut" runat="server"
onclick="LinkButton1_Click">""</asp:LinkButton></td>
.cs page:
protected void LinkButton1_Click(object sender, EventArgs e)
{
//After click Log out we need to delete all session values
if (User.IsAuthenticated)**//error is here**
LinkButtonSignInOut.Text = "Sign Out";
else
LabelSignInOut.Text = "Sign In";
Session.RemoveAll();
Response.Redirect("userlogin.aspx");
}
Any suggestions???
thanks!
Check the below code, I have wrote the comment