How to get MVC Action parameter from AuthorizationContext?

asp.net-mvc, custom-action-filter

Solution

Here's how I did it:

var parameters = filterContext.ActionDescriptor.GetParameters();
var values = parameters.Select(s => new 
             {
                 Name = s.ParameterName,
                 Value = filterContext.HttpContext.Request[s.ParameterName]
             });

Problem

I am currently trying to write a custom authentication filter and I need to access the dto that is being passed as a parameter to the action in my filter. Lets say I have an action like this ``` [AuthenticateProfile] public ActionResult EditProfile(ProfileDTO profileDto) { if (ModelState.IsValid) { // Do crazy stuff } return something.... } ``` I need to do my authentication based on some of the properties that are inside profiledto object. I want to know how I can get this object inside my filter from AuthorizationContext.

Original source

Related problems