检测Internet Explorer浏览器版本的问题 [英] Detect Internet explorer browser version problems
问题描述
我逍遥在布局我MVC3应用程序:
I have Getaway in my MVC3 application in Layout :
@if ((Request.Browser.Browser == "IE") && ((Request.Browser.MajorVersion == 7)))
{
//show some content
}
else
{
//show another content
}
我有很多用户抱怨(与Internet Explorer 8的用户)。他们是从我的应用程序的Internet Explorer 7的内容。
有什么毛病我检测Internet Explorer 7版本的方法吗?
我如何才能确保100%在我的应用程序,用户有Internet Explorer 7的版本?
可能这是特定的操作系统的问题?
I have many users complains (users with internet explorer 8). They see Internet explorer 7 content from my app. What wrong with my way of detecting Internet explorer 7 version? How can I be sure for 100% in my application that user have internet explorer 7 version? May be this is specific OS problem?
推荐答案
的问题是,<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.httpbrowsercapabilities.aspx\">HttpBrowserCapabilities又名的Request.Browser
类解析从具有对客户端的信息请求中的的userAgent
头(在你的情况下,浏览器),这可能并不总是100%可靠的用户代理是很容易改变的。
The issue is the HttpBrowserCapabilities aka Request.Browser
class parses the userAgent
header from the request which has information about the client (in your case the browser) which might not always be 100% reliable as user agents are easily changeable.
如果你知道什么值 MajorVersion
正在恢复它的一贯足够你可能把一个修复程序吧。或者你可以尝试检查浏览器比IE8,而不是低(虽然再次,不是100%),例如
If you know what value MajorVersion
is returning and it's consistent enough you could possibly put a fix in for it. Alternatively you could try checking for browsers lower than IE8 instead (again though, not 100%) e.g.
@if ((Request.Browser.Browser == "IE") && ((Request.Browser.MajorVersion < 8)))
{
//show IE7 content
}
else
{
//show IE8+ content
}
这篇关于检测Internet Explorer浏览器版本的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!