ASP.NET Webmethod in aspx.cs page not able to access Page.Request object
-
05-07-2019 - |
Question
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!
Solution
Use,
HttpContext.Current.Request.Cookies
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow