コード例 #1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            // The code below helps to protect against XSRF attacks
            var  requestCookie = Request.Cookies[AntiXsrfTokenKey];
            Guid requestCookieGuidValue;

            if (requestCookie != null && Guid.TryParse(requestCookie.Value, out requestCookieGuidValue))
            {
                // Use the Anti-XSRF token from the cookie
                _antiXsrfTokenValue   = requestCookie.Value;
                Page.ViewStateUserKey = _antiXsrfTokenValue;
            }
            else
            {
                // Generate a new Anti-XSRF token and save to the cookie
                _antiXsrfTokenValue   = Guid.NewGuid().ToString("N");
                Page.ViewStateUserKey = _antiXsrfTokenValue;

                var responseCookie = new HttpCookie(AntiXsrfTokenKey)
                {
                    HttpOnly = true,
                    Value    = _antiXsrfTokenValue
                };
                if (FormsAuthentication.RequireSSL && Request.IsSecureConnection)
                {
                    responseCookie.Secure = true;
                }

                Response.Cookies.Set(responseCookie);
            }

            if (Request.Cookies["lang"] == null)
            {
                //Write cookie with default lang
                HttpCookie langCookie = new HttpCookie("lang");
                langCookie.Value   = "en-US";
                langCookie.Expires = DateTime.Now.AddDays(7);
                Response.Cookies.Add(langCookie);
            }

            if (Request.Cookies["currency"] == null)
            {
                //Write coockie with default currency
                HttpCookie currencyCookie = new HttpCookie("currency");
                currencyCookie.Value   = "USD";
                currencyCookie.Expires = DateTime.Now.AddDays(7);
                Response.Cookies.Add(currencyCookie);
            }

            Thread.CurrentThread.CurrentCulture =
                CultureInfo.CreateSpecificCulture(CookieHelper.CheckCookie("lang", "en-Us"));
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(CookieHelper.CheckCookie("lang", "en-Us"));

            Page.PreLoad += master_Page_PreLoad;
        }
コード例 #2
0
        internal void PopulateAuction()
        {
            //load query string and pass to method
            var currency = CookieHelper.CheckCookie("currency", "USD");
            var qs       = UrlHelper.GetQueryString("Id");
            var vm       = _pModel.LoadAuction(qs, currency, new CurrencyExchangeRepository());

            if (vm != null)
            {
                try
                {
                    _pView.AuctionTitle     = vm.AuctionTitle;
                    _pView.CreatorName      = vm.CreatorName;
                    _pView.DateCreated      = vm.DateCreated;
                    _pView.LongDescription  = vm.LongDescription;
                    _pView.Price            = vm.ActualPrice;
                    _pView.ShortDescription = vm.ShortDescription;
                    _pView.bids             = vm.bidsViewModel.bidsViewModel.OrderByDescending(x => x.Value).ToList();
                    _pView.listOFImages     = vm.imgModel;
                    _pView.Currency         = currency;
                    _pView.DataEnd          = vm.DateEnd;
                    _pView.IsEnded          = vm.IsEnded;

                    if (_pView.listOFImages != null)
                    {
                        foreach (var item in _pView.listOFImages)
                        {
                            if (item.IsThumbnail)
                            {
                                _pView.Thumbnail = ImageHelper.GetUrlForImage(item.Id, item.Extension);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Elmah.ErrorSignal.FromCurrentContext().Raise(e);
                    throw e;
                }
            }
            else
            {
                throw new HttpException(404, "Not found auction with ID: " + qs);
            }
        }
コード例 #3
0
        internal void PopulateAuctionList()
        {
            var qs = UrlHelper.GetQueryString("category");
            var vm = _pModel.LoadAuctions(qs, CookieHelper.CheckCookie("currency", "USD"));

            if (vm != null)
            {
                _pView.vm = vm.mainList;
            }
            else
            {
                throw new HttpException(404, "Not found selected category: " + qs);
            }

            List <AuctionListSingleElemVM> list = new List <AuctionListSingleElemVM>();

            foreach (var item in _pView.vm)
            {
                if (!item.IsEnded)
                {
                    list.Add(item);
                }
            }
        }
コード例 #4
0
ファイル: SortControl.ascx.cs プロジェクト: wkmalek/AHMVP
 protected override void FrameworkInitialize()
 {
     System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(CookieHelper.CheckCookie("lang", "en-Us"));
     base.FrameworkInitialize();
 }