question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Blazor] HttpClient error when url starts with '/'

See original GitHub issue

Describe 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:

  1. Using ASP.NET Core 3.0 preview 4
  2. Create a new blazorhosted project
  3. Go to FetchData.razor and change the url from api/SampleData/WeatherForecasts to /api/SampleData/WeatherForecasts
  4. Run the app and navigate to /fetchdata

Screenshots

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
SteveSandersonMScommented, May 24, 2019

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.

1reaction
codemonkey85commented, May 19, 2019

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}");

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found