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

Conversation

Daniel15
Copy link
Contributor

Related to issue #409. The HttpHeaderValueProviderFactory only enables the HttpHeaderValueProvider if the URL starts with "/api". When running the NuGet Gallery under a subdirectory (eg. http://devlocal/nuget/), the URL will not start with /api and hence the value provider is not added correctly.

@Daniel15
Copy link
Contributor Author

An alternate fix would be to trim the request.ApplicationPath from the start of the URL before checking if it starts with "api"

@@ -10,7 +10,7 @@ public override IValueProvider GetValueProvider(ControllerContext controllerCont
var request = controllerContext.RequestContext.HttpContext.Request;

// 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.

@pranavkm
Copy link
Contributor

I sent out a separate pull request with the fix #488

@pranavkm pranavkm closed this Apr 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants