0
我试图将值传递给自定义属性从视图方在ASP MVC。我处理的流程是这样的 - >在Asp.net MVC我如何通过自定义属性中的参数动态
- 填充员工详细的保存按钮
- 点击
- 密码窗口已打开
- 这个密码,我想通过自定义属性(卡住这里)
- 条件将检查密码是否正确与否
下面是我的自定义属性
public class LevelSecurityAttribute : ActionFilterAttribute
{
public string PageName {get;set;}
public string Password { get; set; }
public string InvokeMethod { get; set; }
public void LevelSecurity(string pagename,string invokemethod,string password)
{
this.PageName = pagename;
this.Password = password;
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//My Condition logic
base.OnActionExecuting(filterContext);
filterContext.Result=new RedirectResult("~/"+PageName+"/"+InvokeMethod);
}
}
下面是我的操作方法
[HttpPost]
[ValidateAntiForgeryToken]
[LevelSecurity(PageName = "DocumentType", InvokeMethod = "Index", Password = **Need pass Password from View side stuck here**)]
public ActionResult Create(EmployeeMaster Employee,string password)
{
//Insert Employee Data if Password is Valid
return View();
}
请朋友帮助我,如果我的观念是错误的,请让我知道。
换句话说,你*不能*传递密码,但你可以访问请求上下文并从那里获取值。 –
是的......无论如何,我不认为OP会在这种情况下取得任何成功。客户是否应该在每次请求时都传递密码? –
感谢您的回复 –