How can i resolve a virtual path to a file into a path, suitable for the browser, from within a generic .ashx handler?
e.g. i want to convert:
~/asp/ClockState.aspx
into
/NextAllowed/asp/ClockState.aspx
If i were a WebForm Page
, i could call ResolveUrl
:
Page.ResolveUrl("~/asp/ClockState.aspx")
which resolves to:
/NextAllowed/asp/ClockState.aspx
But i'm not a WebForm Page, i'm a generic handler. You know, that IHttpHandler
object with all kinds of things injected:
public class ResetClock : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
//[process stuff]
//Redirect client
context.Response.Redirect("~/asp/ClockState.aspx", true);
}
public bool IsReusable { get { return false; } }
}
Response.Redirect(...)
and it didnt' take into account the virtual folder. But bothVirtualPathUtility
and justRedirect
work. +1 accepted. – Polybius