Cannot access Session, Page_Load or other methods in a page with Page Methods

By Peter Bromberg

There are a lot of forum posts - both here and elsewhere - asking why you cannot access ASP.NET Page class lifecycle methods. The explanation is simple.

Page Methods must be static. No instance of the Page class is ever created when you call a Page Method. Therefore, there is no Page_Load, no Session is ever instantiated, and so on.  If you want to call other methods on a Page from within a Page Method, then they also must be marked static.

Cannot access Session, Page_Load or other methods in a page with Page Methods  (1337 Views)