I am brand new to ASP.NET, and I\'m trying to find a way to easily redirect an unauthenticated user from any page on the site to the logon page. I would prefer to not put th
I used the below code snippet and found it to be very elegant not requiring to write any redirect statements. MVC takes care of the redirection based on the forms login page configuration and upon successfull login/registration, the user is sent back to the initial requested page
if (!User.Identity.IsAuthenticated)
{
//return new HttpUnauthorizedResult(); //This or the below statement should redirect the user to forms login page
return new HttpStatusCodeResult(System.Net.HttpStatusCode.Unauthorized);
}