How would you detect the current browser in an Api Controller?

后端 未结 2 406
-上瘾入骨i
-上瘾入骨i 2020-12-17 10:06

I\'m trying to detect the current web browser within one of my Api Controllers in my program using MVC4. Everywhere I look people say to use Request.Browser, h

2条回答
  •  余生分开走
    2020-12-17 10:59

    You could do something like following too from within the Web API's action:

    System.Net.Http.HttpRequestMessage currentRequest = this.Request;
    System.Net.Http.Headers.HttpHeaderValueCollection userAgentHeader = currentRequest.Headers.UserAgent;
    

提交回复
热议问题