Reputation: 1032
I'm working over a small project core, which was born more than 1 year ago.
I have to enable sliding expiration and I wanted to know if it was now supported out-of-the-box in SS.
Do somebody know if there is a way to add the sliding expiration without having to mark all the POCOs with the attribute?
Upvotes: 0
Views: 311
Reputation: 143369
The filters in ServiceStack's Request Pipeline support the same signatures where anything that can be done in a Request or Response Filter Attribute can also be done in a Global Request or Response Filter.
The sliding Sessions example that uses [SlideExpiration]
Response Filter Attribute, e.g:
public class SlideExpirationAttribute : ResponseFilterAttribute
{
...
public override void Execute(
IHttpRequest req, IHttpResponse res, object requestDto)
{
var session = req.GetSession();
if (session != null) req.SaveSession(session, this.Expiry);
}
}
Is just re-saving the Session so it gets resaved with a new Session Expiry, this can instead be done in a Global Response Filter with:
GlobalResponseFilters.Add((req, res, dto) =>
{
var session = req.GetSession();
if (session != null)
req.SaveSession(session);
});
Upvotes: 1