YAFLogo

Phe0n1x
  • Phe0n1x
  • 80% (Honored)
  • YAF Lover Topic Starter
14 years ago
Bug Fixed: Windows 7 displaying as WinNT
In the project YAF.Classes.Utils in the code file YafContext.cs in the InitUserAndPage() function on line 878 the code needs to be changed from

else if (HttpContext.Current.Request.UserAgent.IndexOf("Windows NT 7.0") >= 0)

to
else if (HttpContext.Current.Request.UserAgent.IndexOf("Windows NT 6.1") >= 0)

with the surounding code, it would go from this

if ( HttpContext.Current.Request.UserAgent != null )
{
	if (HttpContext.Current.Request.UserAgent.IndexOf("Windows NT 5.2") >= 0)
		platform = "Win2003";
	else if (HttpContext.Current.Request.UserAgent.IndexOf("Windows NT 6.0") >= 0)
		platform = "Vista";
	else if (HttpContext.Current.Request.UserAgent.IndexOf("Windows NT 7.0") >= 0)
		platform = "Win7";
	else
	// check if it's a search engine spider...
	isSearchEngine = General.IsSearchEngineSpider(HttpContext.Current.Request.UserAgent);
}

to this:

if ( HttpContext.Current.Request.UserAgent != null )
{
	if (HttpContext.Current.Request.UserAgent.IndexOf("Windows NT 5.2") >= 0)
		platform = "Win2003";
	else if (HttpContext.Current.Request.UserAgent.IndexOf("Windows NT 6.0") >= 0)
		platform = "Vista";
	else if (HttpContext.Current.Request.UserAgent.IndexOf("Windows NT 6.1") >= 0)
		platform = "Win7";
	else
	// check if it's a search engine spider...
	isSearchEngine = General.IsSearchEngineSpider(HttpContext.Current.Request.UserAgent);
}
----------------
Google Chrome reporting as AppleMAC-Safari 5.0

It turns out .NET itself reports it incorrectly so we must add an if statement.
Project: YAF.Classes.Utils
Context.cs (YAF.Classes.Utils.YafContext)
function InitUserAndPage()
below line 868 add

                    
if (HttpContext.Current.Request.UserAgent.ToLower().Contains("chrome"))
    browser = "Chrome 2.0";

with surrounding code:


string browser = String.Format( "{0} {1}", HttpContext.Current.Request.Browser.Browser, HttpContext.Current.Request.Browser.Version );
if (HttpContext.Current.Request.UserAgent.ToLower().Contains("chrome"))
    browser = "Chrome 2.0";

bool isSearchEngine = false;

This should fix that annoying "AppleMAC-Safari 5.0" statement where Chrome should be.

ISSUE WITH FIX: If M$ fixes this, it will need to be changed.


Sponsor

Mek
  • Mek
  • 100% (Exalted)
  • YAF Developer
14 years ago
Champ!

FP:Mek

UserPostedImage

"It's a case of RTFM.. the only problem being we don't have a manual!"

When I post FP:Mek in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting. (Yes I stole this off Ederon 🙂 )
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button