Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A recent addition to ServiceStack is the ability to register custom Request and Response filters. These should be registered in your AppHost.Configure() onload script:

  • The Request Filters are applied before the service gets called and accepts: (IRequest, IResponse, RequestDto) e.g:
//Add a request filter to check if the user has a session initialized
this.RequestFilters.Add((req, res, requestDto) => {
    var sessionId = req.GetCookieValue("user-session");
    if (sessionId == null)
  • The Response Filters are applied after your service is called and accepts: (IRequest, IResponse, RequestDto) e.g:
//Add a response filter to add a 'Content-Disposition' header so browsers treat it as a native .csv file
this.ResponseFilters.Add((req, res, dto) => {
    if (req.ResponseContentType == ContentType.Csv)
        string.Format("attachment;filename={0}.csv", req.OperationName));

Tip: If you're writing your own response to the response stream inside the response filter, add res.EndRequest(); to signal to ServiceStack not to do anymore processing for this request.

Message Queue Endpoints

Non-HTTP requests like Redis MQ are treated as Internal Requests which only execute the alternate GlobalMessageRequestFilters and GlobalMessageResponseFilters and Action Filter attributes.

Something went wrong with that request. Please try again.