Hey there! I'm looking to restrict user access to my page only if they are using Chrome or IE8-9. I've implemented this restriction in the code behind, as shown below, and attempted to hide the main div element.
protected void Page_Load(object sender, EventArgs e)
{
System.Web.HttpBrowserCapabilities browser = Request.Browser;
if (browser.Type.ToString().ToLower().StartsWith("ie"))
{
if (Convert.ToDecimal(browser.Version) < 8 || Convert.ToDecimal(browser.Version) > 9)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "pop", "<script>alert('Your browser is not supported. Please use Chrome or IE7,IE8,IE9');</script>", false);
pagecontainer.Attributes["style"] = "visible:none";
return;
}
}
else if (!browser.Type.ToString().ToLower().StartsWith("chrome"))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "pop", "<script>alert('Your browser is not supported. Please use Chrome or IE7,IE8,IE9');}</script>", false);
pagecontainer.Attributes["style"] = "visible:none";
return;
}
//blah blah
}
<div id="pagecontainer" runat="server" >Page Content Goes Here</div>
However, it seems that the div is not being hidden as intended. While I could redirect users to a warning page, I'd prefer to explore alternatives. Any suggestions?