Will code in finally run after a redirect?

后端 未结 10 1462
别跟我提以往
别跟我提以往 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:48

    Try this:

    try
    {
      Response.Redirect("http://www.google.com");
    }
    finally
    {
       // Will this code run?
      // yes :)
      Response.Redirect("http://stackoverflow.com/questions/3668422/will-code-in-finally-run-after-a-redirect");
    
    }
    

提交回复
热议问题