Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which layer is the best to add a new method?
Message
De
11/07/2015 04:11:24
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01619738
Message ID:
01621972
Vues:
52
>>>UPDATE. Found this http://stackoverflow.com/questions/872796/asp-net-mvc-accessing-view-model-from-a-custom-action-filter which may be a way to go.
>>
>>I've only used the approach with WebAPI rather than the MVC model but they are substantially the same. Looks like that might work.
>
>We're also using API Controller and the code from that link is not working.
>
>Here is what I am trying and can not figure out how to get to the model:
>
>
>using System;
>using System.Collections.Generic;
>using System.Linq;
>using System.Net;
>using System.Net.Http;
>using System.Web;
>using System.Web.Http.Controllers;
>using System.Web.Http.Filters;
>using Glimpse.Core.Tab.Assist;
>
>namespace SysManager.Web.Infrastructure.Filters.Api
>{
>    public class AuditActionFilter : ActionFilterAttribute
>    {
>        public override void OnActionExecuting(HttpActionContext filterContext)
>        {
>
>            var model = filterContext.ControllerContext.Controller; // ViewData.Model is not working here
>            base.OnActionExecuting(filterContext);
>        }       
>    }
>}
Not sure about using Model but you can probably get all you need to know about the request. e.g:
var controller = actionContext.ControllerContext.ControllerDescriptor.ControllerName;
var method = actionContext.ActionDescriptor.ActionName;
//Assuming you know the type passed in the request:
var  info = (NewAllocInfo)actionContext.ActionArguments["info"];
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform