[Blazor] HttpClient error when url starts with '/'
See original GitHub issueDescribe the bug
Attempting to make an http call in blazor client-side, using a url that starts with “/”, (e.g. “/api/GetValues”) results in:
System.ArgumentException: Only 'http' and 'https' schemes are allowed.
To Reproduce
Steps to reproduce the behavior:
- Using ASP.NET Core 3.0 preview 4
- Create a new blazorhosted project
- Go to FetchData.razor and change the url from
api/SampleData/WeatherForecasts
to/api/SampleData/WeatherForecasts
- Run the app and navigate to
/fetchdata
Screenshots
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (6 by maintainers)
Top Results From Across the Web
[Blazor] HttpClient error when url starts with '/' · Issue #9562
Attempting to make an http call in blazor client-side, using a url that starts with "/", (e.g. "/api/GetValues") results in: System.
Read more >Why am i getting a http client error in blazor?
I keep getting a error in a Blazor app while trying to navigate to it's login page. I think the error is coming...
Read more >Global HTTP Error Handling in Blazor WebAssembly
In this article, we are going to learn about handling HTTP errors in the Blazor WebAssembly application. We are going to start with...
Read more >Httpclient uri string is too long error : r/Blazor
I started developing not too long ago and I started off with blazer server. Now I want to have some experience with the...
Read more >Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve investigated, and it is a Mono issue. Filed https://github.com/mono/mono/issues/14630 and closing as external.
Thanks to everyone who posted workaround suggestions.
I’m seeing the same issue following along with the workshop. According to the docs in https://github.com/dotnet-presentations/blazor-workshop/blob/master/docs/03-show-order-status.md#polling-for-order-details I’m supposed to use:
orderWithStatus = await HttpClient.GetJsonAsync<OrderWithStatus>($"/orders/{OrderId}");
Turns out, removing the first ‘/’ on the route (in front of ‘orders’) fixes the issue:
orderWithStatus = await HttpClient.GetJsonAsync<OrderWithStatus>($"orders/{OrderId}");