.net - Getting browser information from IOwinContext -
how can browser iowincontext?
i attempting log requests alongside responses owin middleware (code below).
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} {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); //??? }
you can obtain user-agent header request:
context.request.headers.get("user-agent")
Comments
Post a Comment