page redirect from custom file

  1. Page_Unload server event is not what you thought, you can not redirect there.
  2. The content of Custom File is HTML for showing, you should not use it to do server side work and then redirect.
  3. You better want to read Using Route_Action server event.