HttpRequest.ServerVariables vs HttpRequest.UserAgent Properties VB.net

我与影子孤独终老i 提交于 2019-12-07 09:16:19

问题


What would be the difference (if any) and advantages/disadvantages between these two properties used to determine the user agent?

Dim strUserAgt as String
userAgent = Request.userAgent

vs.

Dim strUserAgt as String = Request.ServerVariables("HTTP_USER_AGENT")

回答1:


Source: How to determine browser type in server-side code without the BrowserType object in ASP.NET

In ASP.NET, you can access the Request.ServerVariables collection or use the new Request.UserAgent property to retrieve the HTTP_USER_AGENT header value.

There are no difference, both will retrieve same thing HTTP_USER_AGENT header value.

Check Request.ServerVariables Collection and IIS Server Variables if you want to dig it in deep. These server variables collection values somewhat depend ond the IIS version also.



来源:https://stackoverflow.com/questions/11472820/httprequest-servervariables-vs-httprequest-useragent-properties-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!