I want to access/intercept a controller action and getting its parameters and values. For example my action is;
public virtual JsonResult ProductAutoCompleteResult(string term, string moduleName)
{
var requestDTO = this.portalServiceClient.CreateRequestDTO<ProductRequestDTO>();
requestDTO.Filter.Keyword = term;
requestDTO.ModuleName = moduleName;
ProductResponseDTO responseDTO =this.portalServiceClient.Channel.GetProductsByProductCategoryTypeCode(requestDTO);
base.CheckResponse(responseDTO);
var products = Mapper.Map<ICollection<ProductModel>>(responseDTO.Products);
var result = products.Where(x => x.Name.Contains(term))
.Select(x => new { id = x.ProductId, value = x.Name });
return new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
In here, I want to access responseDTO 's values while OnActionExecuted event and after filled responseDTO.
You can use the property filterContext.Controller.ViewData.Model
and cast it to the corresponding type if used in an action filter. In case of overriding OnActionExecuted on the controller, either filterContext.Controller.ViewData.Model
or ViewData.Model
property can be used.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.