mvcでロールを有効にする方法?? 私のコードを以下に示します。ロールの作成方法がわからず、データベースに追加したい..
[AttributeUsage(AttributeTargets.All)]
public class UserRightAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//write your user right logic
//if user has right to do nothig otherwise redirect to error page.
string message = "It seems You are not authorize to view this part of the web site!!!.";
RouteValueDictionary redirectTargetDictionary = new RouteValueDictionary();
redirectTargetDictionary.Add("area", "");
redirectTargetDictionary.Add("action", "SaveData");
redirectTargetDictionary.Add("controller", "Home");
redirectTargetDictionary.Add("customMessage", message);
filterContext.Result = new RedirectToRouteResult(redirectTargetDictionary);
}
}