Server.Transfer 方法的命名空间是什么?
我在服务器类下出现红色下划线:
Server.Transfer("~/PostEdit.aspx");
错误是:
无法通过嵌套类型“AnswerQuestion.ThreadTable”访问外部类型“System.Web.UI.Page”的非静态成员
AnswerQuestion 是分部类,ThreadTable 是我制作的自定义类。
I get a red underline under the Server Class:
Server.Transfer("~/PostEdit.aspx");
The mistake is:
Cannot access a non-static member of outer type 'System.Web.UI.Page' via nested type 'AnswerQuestion.ThreadTable'
AnswerQuestion is the partial class and ThreadTable is a custom class that I made.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不在
Page
实例内部,因此您无权访问Server
属性,该属性是Server
属性的快捷方式HTTP 上下文。使用静态
Current
属性获取当前页面的上下文:You are not inside the
Page
instance, so you don't have access to theServer
property, which is a shortcut to theServer
property in the HTTP context.Use the static
Current
property to get the context of the current page:Context.Handler
是HttpContext
的实例。HttpContext
在HttpContext.Current
属性下公开请求的 CURRENT 实例,但是当前上下文也可以在 ProcessRequest 方法中的HTTPHandlers
中传递:Context.Handler
is an instance of anHttpContext
.HttpContext
exposes the CURRENT instance for the request under theHttpContext.Current
property, however the current context can also be passed inHTTPHandlers
in the ProcessRequest method:该异常清楚地表明您正在访问类中的非静态成员。它与 Server.Transfer() 无关。
The exception clearly says that you are accessing a non-static member in your class. It has nothing to do with Server.Transfer().