Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Based on @tvanfosson's direction, I came up with a class that does what I need. Note that the <code>GetRouteData</code> actually looks at the <code>AppRelativeCurrentExecutionFilePath</code> and the <code>PathInfo</code> properties on the <code>RequestContextBase</code> class, not the <code>Url</code> property.</p> <pre><code>public class RouteInfo { public RouteInfo(RouteData data) { RouteData = data; } public RouteInfo(Uri uri, string applicationPath) { RouteData = RouteTable.Routes.GetRouteData(new InternalHttpContext(uri, applicationPath)); } public RouteData RouteData { get; private set; } //******************** //Miscellaneous properties here to deal with routing conditionals... (e.g. "CanRedirectFromSignIn") //******************** private class InternalHttpContext : HttpContextBase { private HttpRequestBase _request; public InternalHttpContext(Uri uri, string applicationPath) : base() { _request = new InternalRequestContext(uri, applicationPath); } public override HttpRequestBase Request { get { return _request; } } } private class InternalRequestContext : HttpRequestBase { private string _appRelativePath; private string _pathInfo; public InternalRequestContext(Uri uri, string applicationPath) : base() { _pathInfo = uri.Query; if (String.IsNullOrEmpty(applicationPath) || !uri.AbsolutePath.StartsWith(applicationPath, StringComparison.OrdinalIgnoreCase)) { _appRelativePath = uri.AbsolutePath.Substring(applicationPath.Length); } else { _appRelativePath = uri.AbsolutePath; } } public override string AppRelativeCurrentExecutionFilePath { get { return String.Concat("~", _appRelativePath); } } public override string PathInfo { get { return _pathInfo; } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload