protected override string GetRewrittenUrl(HttpApplication app, UrlRewritingState state) { // get it... Match match = Regex.Match(state.UrlWithoutQuery); if (!(match.Success)) throw new InvalidOperationException(string.Format("The value '{0}' is invalid.", state.UrlWithoutQuery)); // what sort of token do we have? string tokenType = match.Groups["tokenType"].Value.ToLower(); if (tokenType == "a") ServiceAuthenticator.Current.ApiUsername = match.Groups["token"].Value; else if (tokenType == "t") ServiceAuthenticator.Current.ApiToken = match.Groups["token"].Value; // rewrite... string url = HttpHelper.CombineUrlParts("~/", match.Groups["preamble"].Value); url = HttpHelper.CombineUrlParts(url, match.Groups["path"].Value); // query? if (!(string.IsNullOrEmpty(state.QueryString))) url = url + "?" + state.QueryString; // return... return url; }
protected override bool ShouldRewriteUrl(UrlRewritingState state) { Match match = Regex.Match(state.UrlWithoutQuery); return match.Success; }