I needed to include a url in a confirmation email from my asp.net app. I am not sure whether it will be deployed to a virtual directory or its own site. Just getting the Authority from the Request will yield no virtual directory, so here’s what i came up with:
const string action = "Login/Confirm";
var uri = new UriBuilder(HttpContext.Current.Request.Url);
uri.Path = VirtualPathUtility.ToAbsolute("~/"+action);
uri.Port = -1;//remove :80 (use default)
var url = uri.ToString() //http://localhost/myapp/login/confirm
There is probably a better way of doing this, but it works.
Posted
06-18-2010 8:36 AM
by
Michael Nichols