My ASP.NET MVC application is a small part of a bigger ColdFusion app that is going to be soon replaced completely. I\'m passing some parameters from ColdFusion part through
The better approach would be to implement a custom ActionFilterAttribute and override the OnActionExecuting method to handle the logic and then just decorate your actions with the attribute.
public class CheckCookieAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// Check your cookie and handle the redirect here, otherwise, do nothing
// You can get to your cookie through the filterContext parameter
}
}
public class ActionController : Controller
{
[CheckCookie]
public ActionResult GetFoo()
{
return View();
}
}
Hope this helps.