Uri
has 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 from editor: Beware, this method does not work as expected. It can cut part of baseUri in some cases. See comments and other answers.
Related Contents:
- Absolute path back to web-relative path
- C# getting the path of %AppData%
- How to check whether a string is a valid HTTP URL?
- System.MissingMethodException: Method not found?
- A potentially dangerous Request.Path value was detected from the client (*)
- Convert file path to a file URI?
- How to omit methods from Swagger documentation on WebAPI using Swashbuckle
- How to find the reason for a failed Build without any error or warning
- How to set session timeout in web.config
- Predefined type ‘System.Object’ is not defined or imported .net 4.6
- .NET Configuration (app.config/web.config/settings.settings)
- Date vs DateTime
- Getting current directory in .NET web application
- Split string based on the first occurrence of the character
- Unrecognized escape sequence for path string containing backslashes
- Where is the constant for “HttpRequest.RequestType” and “WebRequest.Method” values in .NET?
- Read Variable from Web.Config
- How to convert “0” and “1” to false and true
- Validating file types by regular expression
- How can I get the name of a variable passed into a function?
- EPPlus number format
- How do you bind an Enum to a DropDownList control in ASP.NET?
- Extracting Path from OpenFileDialog path/filename
- Compilation Error: The type ‘ASP.global_asax’ exists in both DLLs
- How to list all month names, e.g. for a combo?
- How can I compare (directory) paths in C#?
- Generate a unique id
- How to add New Column with Value to the Existing DataTable?
- MEF with MVC 4 or 5 – Pluggable Architecture (2014)
- How do I force full post-back from a button within an UpdatePanel?
- Error – is not marked as serializable
- ResolveUrl without an ASP.NET Page
- ASP.net page without a code behind
- When using Trusted_Connection=true and SQL Server authentication, will this affect performance?
- Why is there both a System.Net.Http and System.Web.Http namespace?
- ASP.NET Web Api – Startup.cs doesn’t exist
- Difference between using the ASP.NET Core Web Application (.NET Core) with net461 set as the only framework and using the (.NET Framework) template
- Get Absolute URL from Relative path (refactored method)
- How to ensure there is trailing directory separator in paths?
- Having problems with converting my DateTime to UTC
- Use CouchDB with .NET
- Refresh Page C# ASP.NET
- Truncating Query String & Returning Clean URL C# ASP.net
- Cannot resolve DbContext in ASP.NET Core 2.0
- How can I remove item from querystring in asp.net using c#?
- Could not load file or assembly ‘Microsoft.ReportViewer.Common, Version=11.0.0.0
- How to convert DataTable to class Object?
- How to get full host name + port number in Application_Start of Global.aspx?
- Path.Combine and the dot notation [duplicate]
- How do I strip non-alphanumeric characters (including spaces) from a string?