2017-03-04
Visual Studio 2015 with Update 3
參考
HttpRequest.UserAgent 屬性
https://msdn.microsoft.com/zh-tw/library/system.web.httprequest.useragent(v=vs.110).aspx
Default.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="HttpBrowserCapabilitiesDemo.Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div> </form> </body> </html> |
Default.aspx.cs
using System; namespace HttpBrowserCapabilitiesDemo { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { System.Web.HttpBrowserCapabilities browser = Request.Browser; string s = "Browser Capabilities<br /><br />" + "ActiveXControls = " + browser.ActiveXControls + "<br />" + "Adapters = " + browser.Adapters + "<br />" + "AOL = " + browser.AOL + "<br />" + "BackgroundSounds = " + browser.BackgroundSounds + "<br />" + "Beta = " + browser.Beta + "<br />" + "Browser = " + browser.Browser + "<br />" + "Browsers = " + browser.Browsers + "<br />" + "CanCombineFormsInDeck = " + browser.CanCombineFormsInDeck + "<br />" + "CanInitiateVoiceCall = " + browser.CanInitiateVoiceCall + "<br />" + "CanRenderAfterInputOrSelectElement = " + browser.CanRenderAfterInputOrSelectElement + "<br />" + "CanRenderEmptySelects = " + browser.CanRenderEmptySelects + "<br />" + "CanRenderInputAndSelectElementsTogether = " + browser.CanRenderInputAndSelectElementsTogether + "<br />" + "CanRenderMixedSelects = " + browser.CanRenderMixedSelects + "<br />" + "CanRenderOneventAndPrevElementsTogether = " + browser.CanRenderOneventAndPrevElementsTogether + "<br />" + "CanRenderPostBackCards = " + browser.CanRenderPostBackCards + "<br />" + "CanRenderSetvarZeroWithMultiSelectionList = " + browser.CanRenderSetvarZeroWithMultiSelectionList + "<br />" + "CanSendMail = " + browser.CanSendMail + "<br />" + "Capabilities = " + browser.Capabilities + "<br />" + "CDF = " + browser.CDF + "<br />" + "ClrVersion = " + browser.ClrVersion + "<br />" + "Cookies = " + browser.Cookies + "<br />" + "Crawler = " + browser.Crawler + "<br />" + "DefaultSubmitButtonLimit = " + browser.DefaultSubmitButtonLimit + "<br />" + "EcmaScriptVersion = " + browser.EcmaScriptVersion + "<br />" + "Frames = " + browser.Frames + "<br />" + "GatewayMajorVersion = " + browser.GatewayMajorVersion + "<br />" + "GatewayMinorVersion = " + browser.GatewayMinorVersion + "<br />" + "GatewayVersion = " + browser.GatewayVersion + "<br />" + "HasBackButton = " + browser.HasBackButton + "<br />" + "HidesRightAlignedMultiselectScrollbars = " + browser.HidesRightAlignedMultiselectScrollbars + "<br />" + "HtmlTextWriter = " + browser.HtmlTextWriter + "<br />" + "Id = " + browser.Id + "<br />" + "InputType = " + browser.InputType + "<br />" + "IsColor = " + browser.IsColor + "<br />" + "IsMobileDevice = " + browser.IsMobileDevice + "<br />" //+ "Item[String] = " + browser.Item[String] + "<br />" + "Item[String] = " + "略" + "<br />" + "JavaApplets = " + browser.JavaApplets + "<br />" + "JavaScript = " + browser.JavaScript + "<br />" + "JScriptVersion = " + browser.JScriptVersion + "<br />" + "MajorVersion = " + browser.MajorVersion + "<br />" + "MaximumHrefLength = " + browser.MaximumHrefLength + "<br />" + "MaximumRenderedPageSize = " + browser.MaximumRenderedPageSize + "<br />" + "MaximumSoftkeyLabelLength = " + browser.MaximumSoftkeyLabelLength + "<br />" + "MinorVersion = " + browser.MinorVersion + "<br />" + "MinorVersionString = " + browser.MinorVersionString + "<br />" + "MobileDeviceManufacturer = " + browser.MobileDeviceManufacturer + "<br />" + "MobileDeviceModel = " + browser.MobileDeviceModel + "<br />" + "MSDomVersion = " + browser.MSDomVersion + "<br />" + "NumberOfSoftkeys = " + browser.NumberOfSoftkeys + "<br />" + "Platform = " + browser.Platform + "<br />" + "PreferredImageMime = " + browser.PreferredImageMime + "<br />" + "PreferredRenderingMime = " + browser.PreferredRenderingMime + "<br />" + "PreferredRenderingType = " + browser.PreferredRenderingType + "<br />" + "PreferredRequestEncoding = " + browser.PreferredRequestEncoding + "<br />" + "PreferredResponseEncoding = " + browser.PreferredResponseEncoding + "<br />" + "RendersBreakBeforeWmlSelectAndInput = " + browser.RendersBreakBeforeWmlSelectAndInput + "<br />" + "RendersBreaksAfterHtmlLists = " + browser.RendersBreaksAfterHtmlLists + "<br />" + "RendersBreaksAfterWmlAnchor = " + browser.RendersBreaksAfterWmlAnchor + "<br />" + "RendersBreaksAfterWmlInput = " + browser.RendersBreaksAfterWmlInput + "<br />" + "RendersWmlDoAcceptsInline = " + browser.RendersWmlDoAcceptsInline + "<br />" + "RendersWmlSelectsAsMenuCards = " + browser.RendersWmlSelectsAsMenuCards + "<br />" + "RequiredMetaTagNameValue = " + browser.RequiredMetaTagNameValue + "<br />" + "RequiresAttributeColonSubstitution = " + browser.RequiresAttributeColonSubstitution + "<br />" + "RequiresContentTypeMetaTag = " + browser.RequiresContentTypeMetaTag + "<br />" + "RequiresControlStateInSession = " + browser.RequiresControlStateInSession + "<br />" + "RequiresDBCSCharacter = " + browser.RequiresDBCSCharacter + "<br />" + "RequiresHtmlAdaptiveErrorReporting = " + browser.RequiresHtmlAdaptiveErrorReporting + "<br />" + "RequiresLeadingPageBreak = " + browser.RequiresLeadingPageBreak + "<br />" + "RequiresNoBreakInFormatting = " + browser.RequiresNoBreakInFormatting + "<br />" + "RequiresOutputOptimization = " + browser.RequiresOutputOptimization + "<br />" + "RequiresPhoneNumbersAsPlainText = " + browser.RequiresPhoneNumbersAsPlainText + "<br />" + "RequiresSpecialViewStateEncoding = " + browser.RequiresSpecialViewStateEncoding + "<br />" + "RequiresUniqueFilePathSuffix = " + browser.RequiresUniqueFilePathSuffix + "<br />" + "RequiresUniqueHtmlCheckboxNames = " + browser.RequiresUniqueHtmlCheckboxNames + "<br />" + "RequiresUniqueHtmlInputNames = " + browser.RequiresUniqueHtmlInputNames + "<br />" + "RequiresUrlEncodedPostfieldValues = " + browser.RequiresUrlEncodedPostfieldValues + "<br />" + "ScreenBitDepth = " + browser.ScreenBitDepth + "<br />" + "ScreenCharactersHeight = " + browser.ScreenCharactersHeight + "<br />" + "ScreenCharactersWidth = " + browser.ScreenCharactersWidth + "<br />" + "ScreenPixelsHeight = " + browser.ScreenPixelsHeight + "<br />" + "ScreenPixelsWidth = " + browser.ScreenPixelsWidth + "<br />" + "SupportsAccesskeyAttribute = " + browser.SupportsAccesskeyAttribute + "<br />" + "SupportsBodyColor = " + browser.SupportsBodyColor + "<br />" + "SupportsBold = " + browser.SupportsBold + "<br />" + "SupportsCacheControlMetaTag = " + browser.SupportsCacheControlMetaTag + "<br />" + "SupportsCallback = " + browser.SupportsCallback + "<br />" + "SupportsCss = " + browser.SupportsCss + "<br />" + "SupportsDivAlign = " + browser.SupportsDivAlign + "<br />" + "SupportsDivNoWrap = " + browser.SupportsDivNoWrap + "<br />" + "SupportsEmptyStringInCookieValue = " + browser.SupportsEmptyStringInCookieValue + "<br />" + "SupportsFontColor = " + browser.SupportsFontColor + "<br />" + "SupportsFontName = " + browser.SupportsFontName + "<br />" + "SupportsFontSize = " + browser.SupportsFontSize + "<br />" + "SupportsImageSubmit = " + browser.SupportsImageSubmit + "<br />" + "SupportsIModeSymbols = " + browser.SupportsIModeSymbols + "<br />" + "SupportsInputIStyle = " + browser.SupportsInputIStyle + "<br />" + "SupportsInputMode = " + browser.SupportsInputMode + "<br />" + "SupportsItalic = " + browser.SupportsItalic + "<br />" + "SupportsJPhoneMultiMediaAttributes = " + browser.SupportsJPhoneMultiMediaAttributes + "<br />" + "SupportsJPhoneSymbols = " + browser.SupportsJPhoneSymbols + "<br />" + "SupportsQueryStringInFormAction = " + browser.SupportsQueryStringInFormAction + "<br />" + "SupportsRedirectWithCookie = " + browser.SupportsRedirectWithCookie + "<br />" + "SupportsSelectMultiple = " + browser.SupportsSelectMultiple + "<br />" + "SupportsUncheck = " + browser.SupportsUncheck + "<br />" + "SupportsXmlHttp = " + browser.SupportsXmlHttp + "<br />" + "Tables = " + browser.Tables + "<br />" + "TagWriter = " + browser.TagWriter + "<br />" + "Type = " + browser.Type + "<br />" + "UseOptimizedCacheKey = " + browser.UseOptimizedCacheKey + "<br />" + "VBScript = " + browser.VBScript + "<br />" + "Version = " + browser.Version + "<br />" + "W3CDomVersion = " + browser.W3CDomVersion + "<br />" + "Win16 = " + browser.Win16 + "<br />" + "Win32 = " + browser.Win32 + "<br />"; Label1.Text = s; } } } |
Windows 7 x64 + IE 11測試結果
****************************************
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
****************************************
Windows 7 x64 + Chrome 56 測試結果
****************************************
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
****************************************
Windows 7 x64 + FireFox 51.0.1 (64位元) 測試結果
****************************************
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0
****************************************
(完)
相關
[研究][C#][ASP.NET][WebForm] 偵測瀏覽器類型(二)
http://shaurong.blogspot.com/2017/03/caspnetwebform.html
[研究][C#][ASP.NET][WebForm] 偵測瀏覽器類型(一)
http://shaurong.blogspot.com/2017/01/caspnet.html
[研究] 檢查瀏覽器 JavaScript是否支援?是否啟用?
http://shaurong.blogspot.com/2016/01/aspnetc-javascript.html
沒有留言:
張貼留言