ASP.NET is an open-source server-side web application framework that was developed by Microsoft. It is mostly used for building dynamic websites and applications. It is free and a cross-platform framework. So, today we will be checking out the 11 most asked ASP.NET questions.
Answer:
Flurl** includes a **Url.Combine**
.**
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:
PM> Install-Package Flurl.Http
Or get the stand-alone URL builder without the HTTP features:
PM> Install-Package Flurl
Alternative Answer:
Urihas a constructor that should do this for you:
new Uri(Uri baseUri, string relativeUri).
Here’s an example:
Uri baseUri = new Uri("http://www.contoso.com");
Uri myUri = new Uri(baseUri, "catalog/shownew.htm");
Note: Beware, this method does not work as expected. It can cut part of baseUri in some cases.
#asp.net #coding #software-development #faq #object-oriented #csharp #backend #code-quality