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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top