An insane workaround I'm currently trying out is to inject our own HttpCapabilitiesDefaultProvider
which returns a static HttpBrowserCapabilities
. The trick then is to always return the same capabilities object, so by calling base.GetBrowserCapabilities
while using IE9, we've used Newtonsoft to create a serialization, and by saving this string in the source, we can build an IE9 like capabilities object regardless of what browser initiated the request.
public class CustomerHttpCapabilitiesProvider : HttpCapabilitiesDefaultProvider
{
private const string m_IE9Definition = "{\r\n \"$type\": \"System.Web.Mobile.MobileCapabilities, System.Web.Mobile\",\r\n \"UseOptimizedCacheKey\":..... ";
private readonly static Lazy<MobileCapabilities> m_Capabilities = new Lazy<MobileCapabilities>(() => JsonConvert.DeserializeObject<MobileCapabilities>(m_IE9Definition), true);
public override HttpBrowserCapabilities GetBrowserCapabilities(HttpRequest request)
{
return m_Capabilities.Value;
}
}
and then assigning the provider in Application_Start
:
HttpCapabilitiesBase.BrowserCapabilitiesProvider = new CustomerHttpCapabilitiesProvider();
This hasn't really been tested however, unsure of what exactly is the impact of this change.