Will code in finally run after a redirect?

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

Take for example the following code:

   try
   {
      Response.Redirect(someurl);
    }
    finally
    {
       // Will this code run?
    }
10条回答
  •  攒了一身酷
    2021-01-02 11:49

    It will run. Response.Redirect actually throws a ThreadAbortException, so that's why code after that will not run (except anything in a finally block of course).

提交回复
热议问题