Blazor Webassembly, Custom http response headers

Niels Jørgen Nielsen 96 Reputation points
2020-08-07T22:07:57.373+00:00

I'm creating Blazor Webassembly app, which call my Dotnet web API. I'm using the injected http client, and the api call itself run without problems, Postmann & WireShark confirms that my custom response headers from the API is returned correctly. But in the Blazor Webassembly app, there is only one header "content-type". I know that the Blazor Http client is a wrapper around some Javascript, but are there anyone out there that can help with some knowledge or examples on how to get custom response headers thru to the Blazor app.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
41,894 questions
{count} votes

Accepted answer
  1. Niels Jørgen Nielsen 96 Reputation points
    2020-08-10T08:39:12.693+00:00

    It was actually very simple. To allow my custom response headers to be available in a Blazor Webassembly app, One just add below header to the response:

    HttpContext.Response.Headers.Add(" Access-Control-Expose-Headers","YourCustomHeader,YourOtherCustomHeader");

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Fay Wang - MSFT 5,221 Reputation points
    2020-08-10T07:26:12.683+00:00

    Hello,

    Welcome to Microsoft Q&A.

    Currently, Microsoft Q&A supports the products listed over here: supported topics (more to be added later on).

    Your question about Blazor is not supported yet now.

    Thanks.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.