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

Blazor with ODataClient - Location Header is missing #1927

Closed
DanielGlos opened this issue Nov 12, 2020 · 3 comments · Fixed by #1934
Closed

Blazor with ODataClient - Location Header is missing #1927

DanielGlos opened this issue Nov 12, 2020 · 3 comments · Fixed by #1934

Comments

@DanielGlos
Copy link

When creating new entity in client side blazor app with Microsoft.ODataClient I get an exception stating that response to this POST request is missing Location header. When I run fiddle to see what's going on I can see that it actually made 2 requests. First one was CORS preflight request with OPTIONS method. Response to this request does not contain Location header. Second request is the actual POST request and response contains correct location header.

Any idea how to deal with this problem?

Assemblies affected

Microsoft.OData.Client 7.6.4

Reproduce steps

        var dataServiceContext = this.ClientFactory.CreateClient<Container>(new Uri("http://localhost:5000/odata"));
        var newAsset = new CreateAssetDto()
        {
            TechnicalName = "from_client_4",
            DisplayNameFormat = "format from client",
            Icon = "client/icon",
            InheritedFrom = Guid.NewGuid(),
            IsActive = true,
            Translation = new AssetTranslationDto
            {
                Title = "Client Asset",
                Language = "en",
                Description = "This is asset from client"
            }
        };

        dataServiceContext.AddToAssets(newAsset);
        await dataServiceContext.SaveChangesAsync();

Expected result

No exception complaining about location header missing.

Actual result

Exception complaining about location header missing.

@DanielGlos
Copy link
Author

I have modified our server side to include the location header in responses for all OPTIONS requests. When I inspect traffic with fiddler again both requests now contain location header but the exception is thrown anyway. That is really strange...

One thing I don't understand is that in Fiddler the location header I added is not highlighted and the second one is. See the attached image. I'm adding the header like this: context.Response.Headers["Location"] = context.Request.GetEncodedUrl();

location-header

@gathogojr gathogojr self-assigned this Nov 17, 2020
@gathogojr
Copy link
Contributor

@DanielGlos Thank you for bringing the issue to our attention. Are you able to share exception details or a repro?

@AmirImam
Copy link

I have the same issue but in console app. When I call "SaveChanges" after "AddToMyTable", it throws The response to this POST request did not contain a 'location' header. That is not supported, but data has been created into database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants