moath naji
moath naji

Reputation: 661

servicestack GlobalRequestFilters request Dto coming null

I have a ServiceStack GlobalRequestFilters filter in the apphost file that catch the authenticate request, the filter is working fine but the problem is in the dto in req , res and requestDto is null!

this.GlobalRequestFilters.Add((req, res, requestDto) => {
     if (req.OperationName.ToLower()== "authenticate")
     {
         var authData =req.GetDto();
     }
});

Upvotes: 2

Views: 298

Answers (1)

mythz
mythz

Reputation: 143399

The requestDto is passed in the filter itself, i.e:

GlobalRequestFilters.Add((req, res, requestDto) => {
    var authDto = requestDto as Authenticate;
    if (authDto != null)
    {
        //...
    }
});

An alternative approach to the above is to use a Typed Request Filter, e.g:

RegisterTypedRequestFilter<Authenticate>((req, res, authDto) => {
    //...
});

Upvotes: 2

Related Questions