Currently I've got an application running with and angular client, consuming a Web API with Windows Authentication.
Now I'm looking into replacing this front end with Blazor (client-side), however I'm facing some challenges when it comes to authentication.
In angular I just set withCredentials to true in order to submit the required information.
The code below works as intended using Blazor server-side, but since I want to use Blazor client-side it's not an option and doesn't help me much.
IEnumerable<SearchView> searchResults;
int NumberOfItems;
protected override async Task OnInitAsync()
{
using (var client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true }))
{
var result = await client.GetJsonAsync<Response<SearchView>>("http://localhost:80/search");
NumberOfItems = result.TotalItemCount;
searchResults = result.Items;
}
}
}
The above code throws an "PlatformNotsupportedException".
WASM: System.PlatformNotSupportedException: System.Net.Http.HttpClientHandler is not supported on the current platform. WASM: at System.Net.Http.HttpClientHandler.set_UseDefaultCredentials (System.Boolean value) <0x1d63160 + 0x0000c> in <4399d2484a2a46159ade8054ed94c78e>:0
Clearly the code provided is not supported using Blazor client-side, but if there are any alternative ways to achieve what I want to, any pointers and help would be appreciated.
HttpClientHandler
? - mjwills