Will code in finally run after a redirect?

后端 未结 10 1468
别跟我提以往
别跟我提以往 2021-01-02 11:08

Take for example the following code:

   try
   {
      Response.Redirect(someurl);
    }
    finally
    {
       // Will this code run?
    }
10条回答
  •  情深已故
    2021-01-02 12:10

    The code in the finally will run, but it will run before the redirect, since the redirect won't be sent to the browser until the method returns, and the finally code will execute before the method returns.

提交回复
热议问题