Asp.Net Absolute Path of a URL
I have used this in the past:
// Gets the base url in the following format:
// "http(s)://domain(:port)/AppPath"
HttpContext.Current.Request.Url.Scheme
+ "://"
+ HttpContext.Current.Request.Url.Authority
+ HttpContext.Current.Request.ApplicationPath;
Using string interpolation:
string redirectUri = $"{this.Request.Url.Scheme}://{this.Request.Url.Authority}{this.Request.ApplicationPath}account/signedout";
Substitute 'this' for 'HttpContext' or 'HttpContext.Current' based on context.
Old post but here is another slightly less verbose method
var baseUri = new Uri(HttpContext.Current.Request.Url, "/");