/// <summary> /// Checks the browser compatibility. /// </summary> private void CheckBrowserCompatibility() { string javascriptEnabled = Context.Request.Form[javascriptEnabledHiddenField.UniqueID]; browserJavaScriptStatus = (!string.IsNullOrWhiteSpace(javascriptEnabled) && string.Compare(javascriptEnabled, checkValue, StringComparison.OrdinalIgnoreCase) == 0) ? BrowserFeatureStatus.Enabled : BrowserFeatureStatus.Disabled; HttpCookie cookie = Context.Request.Cookies[cookieName]; browserCookieStatus = (cookie != null && string.Compare(cookie.Value, checkValue, StringComparison.OrdinalIgnoreCase) == 0) ? BrowserFeatureStatus.Enabled : BrowserFeatureStatus.Disabled; OnBrowserCompatibilityChecked(EventArgs.Empty); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (!this.Page.IsPostBack) { bool noscript = false; bool.TryParse(Context.Request.QueryString["noscript"], out noscript); if (noscript) { browserJavaScriptStatus = BrowserFeatureStatus.Disabled; browserCookieStatus = BrowserFeatureStatus.Unknown; OnBrowserCompatibilityChecked(EventArgs.Empty); } else { //string url = HttpContext.Current.Request.Url.ToString(); DOESNT WORK IN AZURE //string url = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Headers["Host"] + HttpContext.Current.Request.Url.PathAndQuery; string url = GetRealRequestUri().ToString(); string newUrl = ""; if (url.IndexOf("?") >= 0) { newUrl = url.Substring(0, url.IndexOf("?")); string queryString = url.Substring(url.IndexOf("?")); NameValueCollection parameters = HttpUtility.ParseQueryString(queryString); if (parameters != null && parameters.Count > 0) { if (parameters.AllKeys.Contains("noscript")) parameters.Remove("noscript"); if (parameters.Count > 0) { newUrl = newUrl + "?noscript=true&"; newUrl = newUrl + String.Join("&", parameters.AllKeys.SelectMany(key => parameters.GetValues(key).Select(value => String.Format("{0}={1}", HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(value)))).ToArray()); } else { newUrl = newUrl + "?noscript=true"; } } else { newUrl = newUrl + "?noscript=true"; } } else { newUrl = url + "?noscript=true"; } HtmlGenericControl ctrl = new HtmlGenericControl("NOSCRIPT"); ctrl.InnerHtml = string.Format("<meta http-equiv=REFRESH content=0;URL={0}>", newUrl); Page.Header.Controls.Add(ctrl); } } }