我目前正在尝试编写自定义身份验证过滤器,我需要访问作为参数传递给我的过滤器中的操作的dto.可以说我有这样的动作 [AuthenticateProfile]public ActionResult EditProfile(ProfileDTO profileDto) { if
[AuthenticateProfile]
public ActionResult EditProfile(ProfileDTO profileDto)
{
if (ModelState.IsValid)
{
// Do crazy stuff
}
return something....
}
我需要根据profiledto对象中的一些属性进行身份验证.
我想知道如何在AuthorizationContext的过滤器中获取此对象.
我是这样做的:var parameters = filterContext.ActionDescriptor.GetParameters();
var values = parameters.Select(s => new
{
Name = s.ParameterName,
Value = filterContext.HttpContext.Request[s.ParameterName]
});
