I'm attempting to add a "Restrict" attribute in my AppHost. Here is my code:
var restrictAttribute = new RestrictAttribute { ExternalOnly = true };
foreach (var dto in dtos)
{
dto .AddAttributes(restrictAttribute);
}
The DTOs I'm adding them to are ones specifically for POST requests.
The problem I'm facing is that after adding the attributes dynamically, the ServiceStack functionality for the restrict doesn't work. It DOES add the attribute, but doesn't actually restrict anything.
The only way I can make this work is by adding the Restrict Attribute in the Request DTO manually. Am I doing something wrong here?
For dynamically adding Service Attributes you need to add them before
AppHost.Configure()
since they're already initialized by the timeConfigure()
is run, so they need to be either added in AppHost constructor or beforeAppHost.Init()
is called.