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

1

5

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!

Ginetteginevra answered 10/9, 2009 at 1:57 Comment(0)
W
14

Use,

HttpContext.Current.Request.Cookies
Waistcloth answered 10/9, 2009 at 2:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.