Question

I want to implement an alert box to alert the current visitor to log in or register to continue browsing in my ASP.net MVC 4 web application. Can someone explain how to check if the current visitor is already a member or logged in?

Some background about my web app:

  1. Visitors can visit my website to track which events are available (for participation);
  2. Visitors need to register first (on my website) before they can participate at the events.

I appreciate any help.

Was it helpful?

Solution

Try this:

User.Identity.IsAuthenticated 

It returns true if the user is logged in, and false otherwise.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top