private string DetectWebBrowserName() { try { System.Web.HttpBrowserCapabilities browser = Request.Browser; if (browser != null) { // Return the web browser name e.g. IE or Chrome. return browser.Browser; } else { return "Warning: The web browser capabilities cannot be detected!"; } } catch (Exception exception) { // E-mail the exception message to the development team. string body = "<html><body>An error occurred in DetectBrowser():<br/>" + exception.ToString() + "<br/></body></html>"; this.SendAlertEmail(body); return "Error: The web browser cannot be detected!"; } /* string browserCapabilities = "Browser Capabilities\n" + "Type = " + browser.Type + "\n" + "Name = " + browser.Browser + "\n" + "Version = " + browser.Version + "\n" + "Major Version = " + browser.MajorVersion + "\n" + "Minor Version = " + browser.MinorVersion + "\n" + "Platform = " + browser.Platform + "\n" + "Is Beta = " + browser.Beta + "\n" + "Is Crawler = " + browser.Crawler + "\n" + "Is AOL = " + browser.AOL + "\n" + "Is Win16 = " + browser.Win16 + "\n" + "Is Win32 = " + browser.Win32 + "\n" + "Supports Frames = " + browser.Frames + "\n" + "Supports Tables = " + browser.Tables + "\n" + "Supports Cookies = " + browser.Cookies + "\n" + "Supports VBScript = " + browser.VBScript + "\n" + "Supports JavaScript = " + browser.EcmaScriptVersion.ToString() + "\n" + "Supports Java Applets = " + browser.JavaApplets + "\n" + "Supports ActiveX Controls = " + browser.ActiveXControls + "\n" + "Supports JavaScript Version = " + browser["JavaScriptVersion"] + "\n"; */ //this.SendAlertEmail(browser.Browser); } //DetectWebBrowserName() private bool OpenDocument(string fileName) { try { // Get the file name without the path. string fileNameWithoutPath = Path.GetFileName(fileName); // Detect the web browser name: Chrome or Internet Explorer? string browserName = this.DetectWebBrowserName(); if (browserName.Equals("InternetExplorer") || browserName.Equals("IE")) { // Open the solution document file in a new IE browser tab: ScriptManager.RegisterClientScriptBlock(Page, typeof(string), "OpenedSolutionDocumentFile", "var solutionDocumentFile=window.open('documents/" + fileNameWithoutPath + "');", true); } else if (browserName.Equals("Chrome")) { // Open the solution document file in a new Chrome browser tab: ScriptManager.RegisterClientScriptBlock(Page, typeof(string), "OpenedSolutionDocumentFile", "var solutionDocumentFile=window.open('documents/" + fileNameWithoutPath + "','_blank'); solutionDocumentFile.focus();", true); } else { //Neither IE nor Chrome: very unlikely case. // TODO: Firefox } return true; } catch (Exception exception) { // E-mail the exception message to the development team. string body = "<html><body>An error occurred in OpenDocument():<br/>" + exception.ToString() + "<br/></body></html>"; this.SendAlertEmail(body); return false; } } //OpenDocument()