Path.Combine for URLs?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Path.Combine for URLs?

Message par ForumBot »

Path.Combine for URLs?
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Path.Combine for URLs?

Message par ForumBot »

There [is a Todd Menier's comment above](https://stackoverflow.com/questions/372865/path-combine-for-urls/43582421#comment33212350_372865) that [Flurl](https://flurl.dev/) includes a `Url.Combine`.

More details:

Url.Combine is basically a Path.Combine for URLs, ensuring one
and only one separator character between parts:

```
var url = Url.Combine(
"http://MyUrl.com/",
"/too/", "/many/", "/slashes/",
"too", "few?",
"x=1", "y=2"
// result: "http://www.MyUrl.com/too/many/slashes/too/few?x=1&y=2"

```

Get [Flurl.Http on NuGet](https://www.nuget.org/packages/Flurl.Http/):

PM> Install-Package Flurl.Http

Or [get the stand-alone URL builder](https://www.nuget.org/packages/Flurl/) without the HTTP features:

PM> Install-Package Flurl
Répondre

Revenir à « .NET & C# »