Domanda

Assuming I want to keep track of LastVisited field in a DB and I want to update it on each incoming request whether its hitting a ServiceStack API or an MVC Controller. What would be the best way of handling it? Obviously I can put the logic in the Global asax which will run on each request, but how would I access the session object from ServiceStack? or is there a an http handler I can attach to where the ServiceStack's session is available.

È stato utile?

Soluzione

protected override void OnActionExecuting(ActionExecutingContext filterContext)

and

protected override void OnActionExecuted(ActionExecutedContext filterContext)

These will override methods that are part of the System.Web.Mvc.Controller class.

We override this class with a base controller which all our controllers inherit from. You could use either of these for what you are asking.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top