カスタム認証システムを実装するための次のクラスがあります:-
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class CheckUserPermissionsAttribute : ActionFilterAttribute
{
Repository repository = new Repository();
public string Model { get; set; }
public string Action { get; set; }
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
string ADusername = filterContext.HttpContext.User.Identity.Name.Substring(filterContext.HttpContext.User.Identity.Name.IndexOf("\\") + 1);
if (!repository.can(ADusername,Model,Action)) {
filterContext.Result = new HttpUnauthorizedResult("You cannot access this page");
}
base.OnActionExecuting(filterContext);
}
}
しかし、現在、Firefox を使用して Web アプリケーションにアクセスすると、 filterContext.Result = new HttpUnauthorizedResult("You cannot access this page");
ユーザー名とパスワードを永久に入力するためのプロンプト ウィンドウが表示され続けます。filterContext.Result = new HttpUnauthorizedResult("You cannot access this page");
を返す代わりに、「このアクションを実行する権限がありません..」などのメッセージを表示するビューに戻るように、アクション メソッドを変更する方法はあり ますか。ありがとう