Closed nickbeaugie closed 8 years ago
I suspect the Identity.ClientKey is null. Have you implemented a client key retrieval ?
@stefanprodan - that is indeed the problem!
This was my existing code:
protected override RequestIdentity SetIndentity(HttpRequestMessage request)
{
var authContext = AuthContext.GetCurrent();
var clientIp = request.GetClientOrForwardedForIpAddress();
return new RequestIdentity
{
ClientKey = authContext != null ? authContext.ClientId : null,
ClientIp = clientIp != null ? clientIp.ToString() : null,
Endpoint = request.RequestUri.AbsolutePath
};
}
I changed this one line:
ClientKey = authContext != null ? authContext.ClientId : "anon",
And that solved it. Thanks so much!
The thing is, this is all mature code that my predecessor wrote and has worked well in production. It must be that ClientRules are handled in a different way.
I am updating an existing application that has used WebApiThrottle for a number of years.
I want to make use of the
ClientRules
feature. This should be as simple as adding a few extra lines to the creation of the policy as shown here.However, when running the application, I get the following exception.
Is there something I've missed? I've tried all kinds of variations, too tedious to list here.