aspx.cs页面中的ASP.NET Webmethod无法访问Page.Request对象
-
05-07-2019 - |
题
有没有人知道如何使用aspx.cs页面中的[WebMethod]属性访问静态方法中的HttpRequest.Cookies?
它不会让我这样做,因为方法是静态的。
[WebMethod]
public static bool PostToTwitter(string identityUrl, string message, bool autoFollow)
{
Page.Request.Cookies -- object reference is required for non-static field
谢谢!
解决方案
使用,
HttpContext.Current.Request.Cookies
不隶属于 StackOverflow