Jump to content

ASP.NET Security - IsAuthenticated


kevin.upshaw

Recommended Posts

Hi. Wonder if anyone can help. I am trying to build a website where users can log in to their account, and then place an order for an item, edit their details etc. However, am using the following code upon loading the myAccount.cshtml page: if (WebSecurity.IsAuthenticated == false) { Response.Redirect("~/"); } So that if the user is not logged in it directs them to the home page to then login. However I am finding that even when the user has logged in, as soon as they come away from the My Account area - it logs them out and they then have to log back in. How could I make this so it persistently keeps the user logged in until they manually log out with the button I have created. Thanks. Kevin

Link to comment
Share on other sites

Forgive me, am new to ASP.NET, am doing a web design module in my degree and am trying to build a website from scratch for my assignment. I had (perhaps foolishly) included the code: <a href="@{WebSecurity.Logout();}"> In a breadcrumb style bar to which (in my thinking) the user could then click the link which would log them out, however - from what you just said I have realised that every time the page is rendered the user will then be logged out - I was staring at the screen far to long yesterday. What would you suggest the best way to allow someone to logout? Thanks. Kevin

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...