我想做一个AuthorizeAttribute包含Message属性的自定义。问题是,我的 FormsAuthentication 重定向到指定的 loginUrl。该视图如何访问属性的 Message 属性?
例如,我使用自定义 AuthorizeAttribute 执行此操作
[Authorize(Message="You must be logged in to see user settings.")]
public ActionResult Settings()
{
return View();
}
FormsAuthentication如果用户未登录,它将被重定向到 /Account/LogOn(感谢 web.config 中的设置)。我想在登录视图上显示“您必须登录才能查看用户设置”,以便用户知道为什么他们被重定向到登录页面