Sergey
Sergey

Reputation: 3213

ASP.NET Webmethod in aspx.cs page not able to access Page.Request object

Does anyone know how to access HttpRequest.Cookies within a static method with [WebMethod] attribute from an aspx.cs page?

It won't let me do it because method is static .

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

Thanks!

Upvotes: 5

Views: 6857

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94653

Use,

HttpContext.Current.Request.Cookies

Upvotes: 14

Related Questions