有没有人知道如何使用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

谢谢!

有帮助吗?

解决方案

使用,

HttpContext.Current.Request.Cookies
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top