简体   繁体   中英

How to call from Global.asax a method that is in a page's codebehind?

I have an ASP.NET project that contains several pages. In one of the pages' code behind, for example i have a CheckSecurity() function. I want to call this method from Global.asax. I want to use this CheckSecurity() method in Session_Start().

Is it possible to call a method like that from Global.asax Session_Start() ?

Thanks in advance.

创建一个class ,将CheckSecurity()方法放入该类中,然后在Global.asax Session_Start()方法或任何其他page调用该方法。

您可以将页面方法设为静态,并且可以从global.asax中调用它。Session_Start()只需通过global.asax中的aspx.cs页面中的链接调用函数即可

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM