2009-09-10 7 views
3

aspx.cs 페이지의 [WebMethod] 속성을 사용하여 정적 메서드 내에서 HttpRequest.Cookies에 액세스하는 방법을 알고 계십니까?aspx.cs 페이지의 ASP.NET WebMethod가 Page.Request 객체에 액세스 할 수 없음

메서드가 정적이기 때문에 그렇게 할 수 없습니다.

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

고마워요!

답변

11

사용,

HttpContext.Current.Request.Cookies 
관련 문제