From within an external class library, I'd like to convert a path like so:
~/bar/gar
to a path like so:
This is an ASP.NET MVC application.
Since we're not in a view, I cannot use the UrlHelper
class from within my external class library. That's because that class is an instance class and it does not have a default, parameterless constructor. It needs an instance of System.Web.Routing.RequestContext
.
Another option I tried was:
var absoluteRedirectUri = System.Web.VirtualPathUtility
.ToAbsolute(settings.Parameters.RedirectUri.Value,
HttpContext.Current.Request.ApplicationPath);
But that still yields /bar/gar instead of http://foo.com/bar/gar.