Skip to content

Instantly share code, notes, and snippets.

@jesulink2514
Created January 3, 2016 22:50
Show Gist options
  • Save jesulink2514/3fa826534e131cadf507 to your computer and use it in GitHub Desktop.
Save jesulink2514/3fa826534e131cadf507 to your computer and use it in GitHub Desktop.
AuditFilter - Paso 3
using System.Linq;
using System.Web.Mvc;
using Microsoft.AspNet.Identity;
namespace AuditSample.Models
{
public class AuditFilter:FilterAttribute, IActionFilter
{
public void OnActionExecuting(ActionExecutingContext filterContext)
{
var model = filterContext.ActionParameters.First().Value as IAuditRequest;
model.Ip = filterContext.HttpContext.Request.UserHostAddress;
model.UserId = filterContext.HttpContext.User.Identity.GetUserId();
}
public void OnActionExecuted(ActionExecutedContext filterContext)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment