我有一个授权过滤器,用于检查用户会话是否有效。
public class ValidateSessionTokenFilter : IAuthorizationFilter
{
public void OnAuthorization(AuthorizationContext filterContext)
{
if (_SessionTokenIsValid() == false)
{
filterContext.HttpContext.Response.SuppressFormsAuthenticationRedirect = true;
filterContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
filterContext.Result = new RedirectResult(_LoginUrl(), false);
}
}
}
我想知道将状态码设置为Unauthorized
然后返回 aRedirectResult
是否会产生冲突?
我应该只返回 aRedirectResult
而不指定Unauthorized
状态代码吗?