hello, I have buttons in my master page that allow users to nevigate in the site without log in. I aso have a shopping cart page and I want to check if the user is log in or not once the user click on button to select products. how can I do it?
I've tried if (HttpContext.Current.User.Identity.IsAuthenticated) Response.Redirect("~/CheckOut.aspx"); else Response.Redirect("~/Login.aspx", true);
and it doesnt work.
thanks.
p.s
what I mean is something like this site - if you want to write a post and you are not loged in it's redirect you to the login page.
Loading
sPosted Sep 4, 2012, 8:22 AM
sPosted Sep 4, 2012, 7:53 AM
where do I need to put the session? because I've tried already what you suggested and it always redirect me to the login page (even if the user is logged in)
Sukesh MarlaPosted Sep 4, 2012, 7:48 AM
Do One thing, After Login Create A sesesison Variable say UserId and store values inside it.
if (Session["UserId"]!=null) Response.Redirect("~/CheckOut.aspx"); else Response.Redirect("~/Login.aspx", true);
after logout do Session.abandon();
Chec this is corerct answer if it helped