【问题标题】:ASP.NET Webmethod in aspx.cs page not able to access Page.Request objectaspx.cs 页面中的 ASP.NET Web 方法无法访问 Page.Request 对象
【发布时间】:2009-09-10 01:57:18
【问题描述】:

有谁知道如何通过 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

谢谢!

【问题讨论】:

    标签: asp.net httprequest webmethod


    【解决方案1】:

    使用,

    HttpContext.Current.Request.Cookies
    

    【讨论】:

      猜你喜欢
      • 2016-01-04
      • 1970-01-01
      • 2013-05-03
      • 2020-07-31
      • 2012-10-07
      • 2012-09-30
      • 1970-01-01
      • 2013-03-27
      • 2019-06-22
      相关资源
      最近更新 更多