3
如何從IOwinContext獲取瀏覽器?從IOwinContext獲取瀏覽器信息
我試圖從我的owin中間件(下面的代碼)旁邊迴應他們的請求。
public async override Task Invoke(IOwinContext context)
{
var sw = new Stopwatch();
sw.Start();
var user = context.Authentication.User.Identity.IsAuthenticated ?
context.Authentication.User.Identity.Name :
"anonymous";
_logger.WriteVerbose(
string.Format("{0} {1} '{2}{3}{4}' @ {5} for {6}",
context.Request.Scheme,
context.Request.Method,
context.Request.PathBase,
context.Request.Path,
context.Request.QueryString,
context.Request.LocalIpAddress,
user));
await Next.Invoke(context);
_logger.WriteVerbose(
string.Format("{0} {1} {2}ms - {3}",
context.Response.StatusCode,
context.Request.Path,
sw.ElapsedMilliseconds,
context.Request.Browser); //???
}
謝謝 - 與https://github.com/ua-parser/uap-csharp我得到的信息我結合需要正確的格式 – Haroon