0
我的应用程序派生自System.Web.Mvc.Controller基类中有一个基础控制器类。
在重写方法“ActionResultExecuting”我有我的业务逻辑,检查存在的身份验证cookie。
如果当前请求没有身份验证Cookie /满足我的业务条件,我需要将请求重定向到注销操作,然后重定向到登录操作。控制器动作从派生控制器类重定向
请找我的代码片段
public class MyBaseController : Controller
{
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
///... User story 1 - Domain1 Cookie present and Domain2 cookie present - Session ID references match in both the cookies
HttpCookie Domain1Cookie= filterContext.HttpContext.Request.Cookies["dm1"];
HttpCookie Domain2Cookie= filterContext.HttpContext.Request.Cookies["dm2"];
if (Domain1Cookie != null && Domain2Cookie != null)
{
string eacCookieValue = Domain1Cookie.Value;
string enrollmentCookieValue = Domain2Cookie.Value;
if (eacCookieValue.Contains(enrollmentCookieValue))
{
string controllerName = RouteData.Values["Controller"].ToString();
string actionName = RouteData.Values["Action"].ToString();
if (controllerName != "Account" && actionName != "Login")
{
////... This is where i need to put my redirection code... Redirect the User to LogOut Action and then redirect to Login
}
}
}
base.OnActionExecuting(filterContext);
}
}
在此先感谢!