User authentication drops in ASP.NET MVC 3 Controller

nicety

New Member
I was wondering why this peice of code would cause the controller to act like the user is not authenticated when they actually are.\[code\] public ViewResult Index() { if (User.Identity.IsAuthenticated == true) { ViewBag.auth = "YES"; } else { ViewBag.auth = "NO"; } var vendors = db.Vendors.Include(v => v.Genre); return View(vendors.ToList()); }\[/code\]The result of ViewBag.auth is "NO".I know that I could use [Authorize] for this class, but I was just wondering why it would return NO. Also, the default location for the login on the MVC application also changes from "Welcome, user" to "Logon". However, if I go to another controller, it displays "Welcome, User".Any help or guidance would be much appreciated :)
 
Back
Top