Run a method in each request in MVC, C#?

前端 未结 2 491
我在风中等你
我在风中等你 2020-11-30 23:28

In WebForm we could write a method in MasterPage.cs and it ran in each request .
e.g:

MasterPage.cs
--------------
protected void Page_Load(object send         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 00:16

    You could use Global.asax Application_AcquireRequestState method which will get called on every request:

    protected void Application_AcquireRequestState(object sender, EventArgs e)
    {
         //...
    }
    

提交回复
热议问题