I have a global authentication request filter suggested by mythz (ServiceStack dev) in this SO answer
My filter:
RequestFilters.Add((httpReq, httpResp, requestDto) => { if (!PublicRoutes.Contains(httpReq.PathInfo)) { new AuthenticateAttribute().Execute(httpReq, httpResp, requestDto); } });
The filter does not work for me when I request ServiceStack Razor pages that inherit dynamic ViewPage
Example / Default.cshtml:
@inherits ViewPage <!DOCTYPE html> <html> <head> <title>HOME</title> ... ... ETC
At the bottom of the answer in the comments, the raiser question suggests similar behavior, but does not accurately describe how to reproduce, so I don't see a solution.
Is there a solution? Did I do something wrong?
UPDATE
I found that I can immediately declare attributes on my page:
@using ServiceStack.ServiceInterface @inherits ViewPage @{ new AuthenticateAttribute().Execute(Request, Response, this); } <!DOCTYPE html> ... ... ETC
Or I'm sure I can create a class that inherits ViewPage, and run them in the Init method and use the new class on the Razor pages.
Both of these solutions seem extraneous and not very dry.
Tyst
source share