Mobile-Fu detects desktop IE as tablet - ruby-on-rails

Usually Majority of IE sends this useragent
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MS-RTC LM 8)
but some IE sends this Useragent
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Tablet PC 2.0; .NET4.0C; .NET4.0E; MS-RTC LM 8)
I have 2 layouts, application.html.haml & application.mobile.haml
As the second one includes "Tablet PC 2.0" Mobile-Fu sets the format to :tablet which not rendering the layout in my rails App.
Kindly help me in fixing this Issue. Thanks!

Temporarily i fixed by changing the user agent if request is from IE & includes Tablet PC,
class ApplicationController < ActionController::Base
before_filter :change_user_agent_for_ie
def change_user_agent_for_ie
if request.env["HTTP_USER_AGENT"].include?("Tablet PC 2.0") && (request.env["HTTP_USER_AGENT"].include?("MSIE"))
request.env["HTTP_USER_AGENT"] = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MS-RTC LM 8)"
end
end
Not sure what will the permanent fix for this.

Related

Change default browser in Embarcadero RAD Studio 10.4

How can I force Rad Studio 10.4 to use my default browser (Firefox) instead of Microsoft Edge when opening web-based documentation?

Can anyone explain the fields in web server log data?

Can anyone tell me the fields' name in following web server log data?
85.214.57.164 - - [27/Mar/2008:22:46:36 -0400] "GET /LongDistance/ServicesAgreement.html?logo=http%3A%2F%2Fwww.antwerpsupporter.be%2Fsubscribe_2_me_to-delete%2Fsm%2Fexported_files1%2Fmosupoz%2Fadusa%2Fojafujo%2Faweji%2F HTTP/1.0" 404 374 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)"
85.214.57.164 - - [27/Mar/2008:22:46:36 -0400] "GET /LongDistance/ServicesAgreement.html?logo=http%3A%2F%2Fwww.math.science.cmu.ac.th%2Flms%2Flib%2Fadodb%2Fpear%2Fnoxifi%2Fezogan%2F HTTP/1.0" 404 374 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)"
85.214.57.164 - - [27/Mar/2008:22:46:37 -0400] "GET /LongDistance/ServicesAgreement.html?logo=http%3A%2F%2Fsans-packing.ru%2Fimg%2Fjipeqap%2Fehudute%2F HTTP/1.0" 404 374 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)"
Explanation -
I am aware of all other fields i.e.
client IP,
Date,
time,
time zone,
method,
URL requested,
protocol,
HTTP status,
bytes sent
But I am not getting last field about browser which is given in bracket.
Can anyone explain this?
I want specially the fields in brackets, i.e.
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)
Any help would be appreciated.
The last field you're interested in looks very much like the user agent (UA) information that web browsers and other HTTP clients send in the User-Agent HTTP request header (see e.g. MDN, Wikipedia, or the HTTP 1.1 specification).
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)
You asked about the portion of the user agent string inside parentheses. That is basically just a comment about the platform/system that the user agent is running on.
In general, I don't think that this string is required to be in any particular format (even though it might look similar for most common user agents) so be careful when attempting to parse this field.
From the HTTP 1.1 specification, RFC 7231 section 5.5.3:
User-Agent = product *( RWS ( product / comment ) )
The User-Agent field-value consists of one or more product identifiers, each followed by zero or more comments (Section 3.2 of [RFC7230]), which together identify the user agent software and its significant subproducts. By convention, the product identifiers are listed in decreasing order of their significance for identifying the user agent software. Each product identifier consists of a name and optional version.
Regarding comments, see RFC 7230 section 3.2.6:
Comments can be included in some HTTP header fields by surrounding the comment text with parentheses. Comments are only allowed in fields containing "comment" as part of their field value definition.
More specifically, UserAgentString.com keeps a detailed list of user agent strings and what they mean, see e.g. here for ones similar to the one you're interested in. Here's a short example:
Mozilla/4.0 (product & product version outside parentheses): "Claims to be a Mozilla based user agent, which is only true for Gecko browsers like Firefox and Netscape. For all other user agents it means 'Mozilla-compatible'."
(In case you're asking yourself why browsers self-identify as Mozilla even when they're something else, see e.g. this other SO question.)
compatible: as above
MSIE 7.0: the actual user agent (Internet Explorer 7)
Windows NT 5.1: operating system version (Windows XP)
.NET CLR 2.0.50727: .NET Framework 2 is installed on the client OS
.NET CLR 1.1.4322: .NET Framework 1.1 is installed on the client OS

In asp.net-mvc, Is there a way to differentiate between IE7 users and IE8 users that are in compatibility mode?

For IE7 users, I want to put in some specific "Please upgrade now" banner. I thought i had this but i found out my banner was popping up on people who had IE8 but had compatibility mode turned on by default.
Is there anyway to differentiate between these two situations so I can change my message from:
Please update from IE7 to You are using IE8 but you are using compatibility mode, please switch this off
Here is the code that i am using now in my View:
You are using <b><% = Request.Browser.Browser + ", Version: " + Request.Browser.Version%>
but if I test in IE8 with compatability view, by using the above code or this code on the client side:
<!--[if lte IE 7]>
it returns true and shows up as IE7. How can i differentiate the two ?
According to user-agents.org and some of the discussion linked by other answers, you can differentiate between the three cases by checking the user agent string you've received.
For MSIE 7.0: Check for MSIE 7.0 and the lack of Trident
For example: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB5; User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; http://bsalsa.com) ; .NET CLR 2.0.50727)
For MSIE 8.0 in compatability mode: Check for MSIE 7.0 and the presence of Trident/4.0
For example: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1;Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0)
For MSIE 8.0 in standard mode: Check for MSIE 8.0
For example: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)
To perform these checks, consult the following tutorial, replacing all of this nonsense about iPhones and mobile devices with the browsers you're checking for. :)
Best of luck with your application.
Putting this
"<meta http-equiv="X-UA-Compatible" content="IE=8">" in your header will make IE8 not load up in compatability mode
Microsoft's Understanding User-Agent Strings document gives a pretty thorough explanation of the user agent strings sent by different IE versions (including compatibility mode). If you determine that a user-agent is displaying MSIE 7.0, look for Trident in the user agent string, which indicates that the browser is actually IE8+ in compatibility mode.
The document has a section explaining the Trident token and how it works.
I believe TGH is right.
Another option is to use jQuery's built-in functions to fully test the: browser type, browser version, and browser mode:
$.browser.msie
$.browser.version
document.documentMode

is there CLR profiler for .NET 4.0 around?

The CLR profiler I downloaded from here link text does not work for my app which is implemented using .NET 4.0. Is there a version for .NET 4.0? Thanks.
UPDATE: The CLR Profiler for .NET Framework 4 is now available here.
I couldn't find the CLR Profiler for .NET 4.0, but you should be able to use the older version if you set the environment variable: COMPLUS_ProfAPI_ProfilerCompatibilitySetting. For more information see this blog post.
Also note that as of .NET 4.0 the CLR outputs some more information to the Event Log to help you diagnose issues loading profilers. You can easily view these logs with the Event Viewer.
CLR Profile 4.0 can be downloaded here:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=f4addc9d-be61-4ebc-90b2-5f50812c2037
it looks like the installer is 64bit only, but you can unpack it using 7z and the 32bit version is inside the package.

jQuery 1.4.2 - " Object doesn't support this property or method" in Internet Explorer 8

I have an issue where my jQuery script reports followign error in Internet Explorer 8
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.4; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; MS-RTC LM 8; MS-RTC EA 2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Mon, 24 May 2010 12:36:55 UTC
Message: Object doesn't support this property or method
Line: 20
Char: 49
Code: 0
My jQuery script is using JQuery UI library v1.8. I am displaying a modal popup dialogue. The contents of the dialogue box is taken from a text file located in the server and i am reading the content using $.ajax() call.
The functionaliy is not affected even when i open the page in IE6/7/8. But above javascript error is shown when i open the page in IE8, When I change the mode to IE7 it works great (Tools --> Developer Tools --> Browser Mode IE7).
Does anyone has resolution to this. Some of the posts suggested using latest version of jQuery UI library. But i have been using it already.
Plase help....
I'm guessing a trailing comma in an object or list of parameters. FF/Webkit is more forgiving of this kind of thing.
example
$('#navigation p').css({
'color' : '#000000',
'font-size' : '10px',
})
should be
$('#navigation p').css({
'color' : '#000000',
'font-size' : '10px'
})

Resources