You can get the raw URL in Owin by referring to the HttpListenerContext that was used to receive the request.
public static string RealUrlFromOwin(HttpRequestMessage request)
{
var owincontext = ((OwinContext) request.Properties["MS_OwinContext"]);
var env = owincontext.Environment;
var listenerContext = (System.Net.HttpListenerContext) env["System.Net.HttpListenerContext"];
return listenerContext.Request.RawUrl;
}
This will not only restore things like trailing / in Url, but also get the Url string before any decoding is applied so that you can distinguish between '!' and% 21, for example.
source
share