Created
January 3, 2016 22:50
-
-
Save jesulink2514/3fa826534e131cadf507 to your computer and use it in GitHub Desktop.
AuditFilter - Paso 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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