1每次在web 服务启动的时候执行;怎么让他每次开一个页面的时候都执行?2如果这样的话性能损失怎么样?

解决方案 »

  1.   

    自定义自己的page handler,然后写上你要执行的代码,就是每次打开页面时执行的了性能要看你执行的代码了,如果你的代码必须在页面打开时候执行,那就无所谓性能不性能了。
      

  2.   


    你要知道Application_Start是干嘛的
    Occurs when application start他只会在你的服务启动时执行
      

  3.   

    application_start 只能是服务器启动时 触发
    要在每个页面 或者某些页面触发 那么最好在管道里面做 moudule hander之类
      

  4.   

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
         //Do some operation 
    }性能提升protected void Application_BeginRequest(Object sender, EventArgs e)
    {
        ThreadPool.QueueUserWorkItem(obj => DoSomething());
    }private void DoSomething()
    {
       //Do some operation 
    }