instead of placing your HttpContext.Request.IsAuthenticated at the controller level, you should place it in the base class class of the controller, which will be inherited throughout your controller using the OnActionExecuting () method override method.
In the base of your controller you must have
public class BaseController : Controller { protected override void OnActionExecuting(ActionExecutingContext ctx) { base.OnActionExecuting(ctx); ViewData["IsAuthenticated"] = HttpContext.Request.IsAuthenticated; } }
and your entire controller should inherit the BaseController class
public class ApplicationController : BaseController
you should now get ViewData["IsAuthenticated"] on the main page.
Edit
With the link you provided and related to what you did, your ApplicationController is a Page Controller, not a base controller. In this example, the ApplicationController is the base controller that the HomeController inherits, but you did what you place the Action method inside your base controller, which is the ApplicationController , so your Index Index method will not be called when you call any page (index page) that not owned by ApplicationController.
rob waminal Aug 08 '10 at 1:21 2010-08-08 01:21
source share