ASP.NET Webmethod on aspx.cs page cannot access Page.Request object

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

This will not allow me to do this because the 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!

+3
source share
1 answer

Using

HttpContext.Current.Request.Cookies
+11
source

Source: https://habr.com/ru/post/1717305/


All Articles