代码之家  ›  专栏  ›  技术社区  ›  Sergey

aspx.cs页中的ASP.NET WebMethod无法访问page.request对象

  •  3
  • Sergey  · 技术社区  · 16 年前

    有人知道如何从aspx.cs页面访问具有[webmethod]属性的静态方法中的httpRequest.cookies吗?

    它不允许我这样做,因为方法是静态的。

    [WebMethod]
    public static bool PostToTwitter(string identityUrl, string message, bool autoFollow)
    {
      Page.Request.Cookies -- object reference is required for non-static field
    

    谢谢!

    1 回复  |  直到 12 年前
        1
  •  12
  •   KV Prajapati    16 年前

    使用,

    HttpContext.Current.Request.Cookies
    
    推荐文章