Exemplo n.º 1
0
        /// <summary>
        /// Test request to see if the fix needs applying
        /// </summary>
        /// <param name="request">request to test</param>
        /// <returns>true if the fix should be applied</returns>
        public static bool IsRequired(HttpRequest request)
        {
            // this fix is for IE only. It isn't needed for IE7 and
            // will only work for IE5.5+
            HttpBrowserCapabilities browser = request.Browser;

            return(browser.IsBrowser("IE") && (browser.MajorVersion == 6 ||
                                               browser.MajorVersion == 5 && browser.MinorVersion >= 5.0));
        }
Exemplo n.º 2
0
 /// <summary>判断当前浏览器是否与指定的浏览器相同
 /// </summary>
 /// <param name="BrowserName">指定进行对比的浏览器</param>
 /// <returns></returns>
 public bool?IsAlikeBrowser(string BrowserName)
 {
     try
     {
         return(bc.IsBrowser(BrowserName));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 3
0
        private static void Application_PostAcquireRequestState(object sender, EventArgs e)
        {
            if (!VirtualDirectoryConfiguration.EcpVirtualDirectoryAnonymousAuthenticationEnabled)
            {
                ExTraceGlobals.RBACTracer.TraceInformation(0, 0L, "Anonymous authentication must be enabled in ECP.");
                throw new ExchangeConfigurationException(Strings.AnonymousAuthenticationDisabledErrorMessage);
            }
            HttpRequest             request = HttpContext.Current.Request;
            HttpBrowserCapabilities browser = request.Browser;

            if (browser != null && browser.IsBrowser("IE") && browser.MajorVersion < 7)
            {
                ErrorHandlingUtil.TransferToErrorPage("browsernotsupported");
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Determines whether this is the specified browser and any of the specified major versions.
 /// </summary>
 public static bool IsBrowser(this HttpBrowserCapabilities browser, string browserName, params int[] majorVersions)
 {
     return(browser.IsBrowser(browserName) && majorVersions.Contains(browser.MajorVersion));
 }
Exemplo n.º 5
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            this.EnsureChildControls();
            if (HttpContext.Current.Error != null)
            {
                this.debugInformation = HttpContext.Current.Error.ToTraceString();
                HttpContext.Current.ClearError();
            }
            if (HttpContext.Current.Request.ServerVariables["X-ECP-ERROR"] != null)
            {
                HttpContext.Current.Response.AddHeader("X-ECP-ERROR", HttpContext.Current.Request.ServerVariables["X-ECP-ERROR"]);
            }
            string            text = base.Request.QueryString["cause"] ?? "unexpected";
            ErrorPageContents contentsForErrorType = ErrorPageContents.GetContentsForErrorType(text);
            string            text2 = null;

            if (text == "browsernotsupported")
            {
                string    helpId   = EACHelpId.BrowserNotSupportedHelp.ToString();
                IThemable themable = this.Page as IThemable;
                if (themable != null && themable.FeatureSet == FeatureSet.Options)
                {
                    helpId = OptionsHelpId.OwaOptionsBrowserNotSupportedHelp.ToString();
                }
                text2 = string.Format(contentsForErrorType.ErrorMessageText, HelpUtil.BuildEhcHref(helpId));
            }
            else if (text == "nocookies")
            {
                HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser;
                if (browser != null && browser.IsBrowser("IE"))
                {
                    text2 = string.Format(Strings.CookiesDisabledMessageForIE, HelpUtil.BuildEhcHref(EACHelpId.CookiesDisabledMessageForIE.ToString()));
                }
            }
            else if (text == "liveidmismatch")
            {
                string value = HttpContextExtensions.CurrentUserLiveID();
                if (string.IsNullOrEmpty(value))
                {
                    contentsForErrorType = ErrorPageContents.GetContentsForErrorType("unexpected");
                }
                else
                {
                    string arg = EcpUrl.EcpVDir + "logoff.aspx?src=exch&ru=" + HttpUtility.UrlEncode(HttpContext.Current.GetRequestUrl().OriginalString);
                    text2 = string.Format(contentsForErrorType.ErrorMessageText, HttpContextExtensions.CurrentUserLiveID(), arg);
                }
            }
            else if (text == "verificationfailed")
            {
                text2 = string.Format(contentsForErrorType.ErrorMessageText, EcpUrl.EcpVDir);
            }
            else if (text == "verificationprocessingerror")
            {
                text2 = contentsForErrorType.ErrorMessageText;
            }
            else if (text == "noroles")
            {
                this.ShowSignOutHint   = true;
                this.ShowSignOutLink   = true;
                this.SignOutReturnVdir = "/ecp/";
            }
            else if (text == "cannotaccessoptionswithbeparamorcookie")
            {
                this.ShowSignOutLink   = true;
                this.SignOutReturnVdir = "/owa/";
            }
            if (string.IsNullOrEmpty(text2))
            {
                this.msgText.Text = contentsForErrorType.ErrorMessageText;
            }
            else
            {
                this.msgText.Text = text2;
            }
            base.Title         = contentsForErrorType.PageTitle;
            this.msgTitle.Text = Strings.ErrorTitle(contentsForErrorType.ErrorMessageTitle);
            this.msgCode.Text  = ((int)contentsForErrorType.StatusCode).ToString(CultureInfo.InvariantCulture);
            HttpContext.Current.Response.StatusCode             = (int)contentsForErrorType.StatusCode;
            HttpContext.Current.Response.SubStatusCode          = contentsForErrorType.SubStatusCode;
            HttpContext.Current.Response.TrySkipIisCustomErrors = true;
            this.causeMarker.Text = "<!-- cause:" + contentsForErrorType.CauseMarker + " -->";
        }
Exemplo n.º 6
0
        private void HandleRequest(HttpContext context, JsonRequest request, ref JsonResponse response)
        {
            context.Response.Clear();
            HttpBrowserCapabilities browser = context.Request.Browser;

            // this is a specific fix for Opera 8.x
            // Opera 8 requires "text/plain" or "text/html"
            // otherwise the content encoding is mangled
            bool isOpera8 = browser.IsBrowser("opera") && (browser.MajorVersion <= 8);

            context.Response.ContentType = (isOpera8) ?
                                           MediaTypeNames.Text.Plain :
                                           JsonWriter.JsonMimeType;

            context.Response.ContentEncoding = System.Text.Encoding.UTF8;
            context.Response.AddHeader("Content-Disposition", "inline;filename=JsonResponse" + JsonServiceHandler.JsonFileExtension);

            response.ID = request.ID;

            System.Reflection.MethodInfo method = this.ServiceInfo.ResolveMethodName(request.Method);

            if (JsonServiceHandler.DescriptionMethodName.Equals(request.Method, StringComparison.Ordinal))
            {
                response.Result = new JsonServiceDescription(this.ServiceInfo.ServiceType, this.serviceUrl);
            }
            else if (method != null)
            {
                Object[] positionalParams = null;
                if (request.NamedParams != null)
                {
                    String[] paramMap = this.ServiceInfo.GetMethodParams(method.Name);
                    positionalParams = new Object[paramMap.Length];
                    for (int i = 0; i < paramMap.Length; i++)
                    {
                        // initially map name to position
                        positionalParams[i] = request.NamedParams[paramMap[i]];
                        if (positionalParams[i] == null)
                        {
                            // try to get as named positional param
                            positionalParams[i] = request.NamedParams[i.ToString()];
                        }
                    }
                }
                else if (request.PositionalParams != null)
                {
                    positionalParams = new object[request.PositionalParams.Length];
                    request.PositionalParams.CopyTo(positionalParams, 0);
                }

                try
                {
                    if (positionalParams != null)
                    {
                        ParameterInfo[] paramInfo = method.GetParameters();
                        for (int i = 0; i < positionalParams.Length; i++)
                        {
                            // ensure type compatibility of parameters
                            positionalParams[i] = JsonReader.CoerceType(paramInfo[i].ParameterType, positionalParams[i]);
                        }
                    }

                    response.Result = method.Invoke(this.Service, positionalParams);
                }
                catch (TargetParameterCountException ex)
                {
                    throw new InvalidParamsException(
                              String.Format(
                                  "Method \"{0}\" expects {1} parameters, {2} provided",
                                  method.Name,
                                  method.GetParameters().Length, positionalParams.Length),
                              ex);
                }
                catch (TargetInvocationException ex)
                {
                    throw new JsonServiceException((ex.InnerException ?? ex).Message, ex.InnerException ?? ex);
                }
                catch (Exception ex)
                {
                    throw new JsonServiceException(ex.Message, ex);
                }
            }
            else
            {
                throw new InvalidMethodException("Invalid method name: " + request.Method);
            }
        }
Exemplo n.º 7
0
 public override bool IsBrowser(string browserName)
 {
     return(_browser.IsBrowser(browserName));
 }