예제 #1
0
        public static LocaleElement DetectLocale(HttpRequest req)
        {
            LocaleElement requiredLoc;

            LocaleHelper hlp  = new LocaleHelper();
            HttpCookie   cook = req.Cookies[LocaleHelper.CONFG_COOKIE_NAME];

            if (req.QueryString["isTransfered"] != null)
            {
                requiredLoc = hlp.GetLocaleByProvider(req.QueryString["isTransfered"]);
            }
            else
            {
                requiredLoc = (cook == null ? hlp.DefaultLocale:hlp.GetLocaleByProvider(cook[LocaleHelper.COOKIE_LANG_NAME]));
            }

            return(requiredLoc);
        }
예제 #2
0
    protected override bool OnBubbleEvent(Object source, EventArgs args)
    {
        if (!(args is CommandEventArgs))
        {
            return(false);
        }

        Control          srcObj = (Control)source;
        Boolean          res    = true;
        CommandEventArgs a      = (CommandEventArgs)args;
        HttpCookie       cook;

        //L2.Text = string.Format("OnBubbleEvent: {0}  /{1}", srcObj.ID, a.CommandName);

        if (srcObj.ID == btnRus.ID || srcObj.ID == btnEng.ID)
        {
            LocaleElement loc = _locHlp.GetLocaleByProvider(a.CommandName);
            if (loc != null)
            {
                cook = Response.Cookies[LocaleHelper.CONFG_COOKIE_NAME];
                cook[LocaleHelper.COOKIE_LANG_NAME] = loc.ProviderName;
                cook.Expires = DateTime.Now.AddYears(50);
                ReadLocale(cook);

                SwitchSiteMapProvider(Request.QueryString["isTransfered"] != null);

                //Response.Redirect( Request.Url.AbsolutePath, true );
                if (Request.QueryString["isTransfered"] == null)
                {
                    Context.Server.Transfer(Request.RawUrl + "?isTransfered=" + CurrentProvidername, true);
                }
                else
                {
                    Context.RewritePath(Request.RawUrl, Request.PathInfo, "");
                }
            }
            else
            {
                return(base.OnBubbleEvent(source, args));
            }
        }
        else if (srcObj.ID == btnHome.ID)
        {
            /*int idx = Request.Url.AbsoluteUri.IndexOf(Request.ApplicationPath);
             * if (idx != -1)
             * {
             *  Context.Response.Redirect(Request.Url.AbsoluteUri.Substring(0, idx), true);
             * }*/
            Context.Response.Redirect(string.Format("{0}{1}{2}:{3}", Request.Url.Scheme, Uri.SchemeDelimiter, Request.Url.Host, Request.Url.Port));
        }
        else
        {
            switch (srcObj.ID)
            {
            case "btnPrev":
            case "btnUp":
            case "btnDown":
            case "btnNext":
                break;

            case "btnLogOff":
                FormsAuthentication.SignOut();
                Session.Abandon();
                Response.Redirect("~/login.aspx");
                break;

            default:
                res = false;
                break;
            }
        }

        return(res);
    }