Zugang zu den QueryString / Sitzung aus einer statischen Methode?

Ich verwenden ASP.Net und eine statische Webmethode /PageMethod, um einige der asynchronen Arbeit.
Meine Frage ist, wie um auf meinen Abfragezeichenfolgen-und Session-Variablen hier?

Ich habe versucht, "HttpContext.Aktuelle" und eine Menge von Informationen hier, aber nicht meine QueryString noch meine Sitzung, und ich weiß nicht, warum.

 [WebMethod(EnableSession=true)]
    public static object Update(string time)
    {
        string timer;
        string lastBidder;
        string price;

        //Countdown timer
        DateTime dt = DateTime.Parse(time);
        dt = dt.AddSeconds(-1.0);
        timer = dt.ToString("HH:mm:ss");

        int auctionID = 6;
        if (!int.TryParse(HttpContext.Current.Request.QueryString["id"], out auctionID))
            throw new Exception("Seitenaufruf ohne ID");

        Business.AuctionHandling ah = new Business.AuctionHandling();
        DAL.Auktion auktion = ah.GetSingleAuction(auctionID);

        price = auktion.AktuellerPreis.ToString("###0.00");

        //this.gvHistory.DataBind();

        List<DAL.Biethistorie> his = ah.GetBidHistoryForAuction(auctionID);
        if (his.Count > 0)
        {
            lastBidder = his[0].Benutzer.Benutzername;
            //History fett
            //gvHistory.Rows[0].Font.Bold = true;
            //gvHistory.Rows[0].ForeColor = System.Drawing.ColorTranslator.FromHtml("#3B4D5F");
            //lblHöchstesGebot.ForeColor = System.Drawing.Color.Black;
        }
        else
        {
            lastBidder = Helper.StringHelper.AuctionDeatil_NoBidder;
            //lblHöchstesGebot.ForeColor = System.Drawing.Color.Red;
        }

        return new
        {
            valueTimer = timer,
            valuePrice = price,
            valueLastBidder = lastBidder
        };
    }

InformationsquelleAutor Kovu | 2009-11-19

Schreibe einen Kommentar