In normal asp.net the following works:
private float getInternetExplorerVersion()
{
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
float rv = -1;
System.Web.HttpBrowserCapabilities browser = Request.Browser;
if (browser.Browser == "IE")
rv = (float)(browser.MajorVersion + browser.MinorVersion);
return rv;
}
but in asp.net mvc2 gives error at “System.Web.HttpBrowserCapabilities browser = Request.Browser;”:
Cannot implicitly convert type ‘System.Web.HttpBrowserCapabilitiesBase’ to ‘System.Web.HttpBrowserCapabilities’
Thanks
Arnab
That’s because the Browser property is of type
HttpBrowserCapabilitiesBaseinstead ofHttpBrowserCapabilities. So either use implicitvaror specify the proper type:or if you prefer typing lots of code: