Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with API header binding when running under a subdirectory #478

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Website/Infrastructure/HttpHeaderValueProviderFactory.cs
Expand Up @@ -10,7 +10,7 @@ public override IValueProvider GetValueProvider(ControllerContext controllerCont
var request = controllerContext.RequestContext.HttpContext.Request; var request = controllerContext.RequestContext.HttpContext.Request;


// Use this value provider only if a route is located under "API" // Use this value provider only if a route is located under "API"
if (request.Path.TrimStart('/').StartsWith("api", StringComparison.OrdinalIgnoreCase)) if (request.Path.Contains("/api/"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be safe to use the Controller as the discriminator. We could do:
if (controllerContext.Controller is ApiController)
{
// ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's an even better idea.

return new HttpHeaderValueProvider(request, "ApiKey"); return new HttpHeaderValueProvider(request, "ApiKey");
return null; return null;
} }
Expand Down