Is the current user anonymous?

If you want to find out if the current visitor is anonymous or logged on, you can use the context to get that information.

bool anonymous = Context.User.Identity.IsAuthenticated == false;

If you just go for SPWeb.Current.Web.CurrentUser, you will get logged on automatically to retrieve the current user.

Technorati Tags: ,