Colourblind

Welcome to Colourblind.

This is the personal web space of Tom Milsom. As much as possible everything is free (as in speach and as in beer).


Make text: Smaller Bigger

Well I didn't know that

Posted by Tom on 11/09/2010 22:24:42

I like to think I know ASP.NET fairly well, but this is the first time I've come across this.

   1:  public void HopefullyRedirect()
   2:  {
   3:      try
   4:      {
   5:          SomeComplicatedCrap();
   6:          Response.Redirect("~/SomeplaceElse.aspx");
   7:      }
   8:      catch (Exception e)
   9:      {
  10:          ReportError(e);
  11:      }
  12:  }

Yeah, I know - catching Exception is bad. But SomeComplicatedCrap has some complicated crap in it. There were HttpWebRequests and XML parsing and all other kinds of stuff. Seriously. Stop looking at me like that. We've all done it. Jeez.

But that's not the point I'm trying to make. Response.Redirect calls Response.End, which calls Thread.Abort, which bubbles a ThreadAbortException. So now every time that method is called I get an email.

What I should have been doing is this.

   1:  public void HopefullyRedirect()
   2:  {
   3:      try
   4:      {
   5:          SomeComplicatedCrap();
   6:          Response.Redirect("~/SomeplaceElse.aspx");
   7:      }
   8:      catch (ThreadAbortException)
   9:      {
  10:          throw;
  11:      }
  12:      catch (Exception e)
  13:      {
  14:          ReportError(e);
  15:      }
  16:  }

I just find it odd that I've never come across this before. Others things I've discovered recently:

  • Wookey Hole has no wookiees
  • But Cheddar Gorge has shitloads of chedar
  • Catcher in the Rye was disappointing
  • However, Jim Beam Straight Rye is great

Edumacating!

Tags: ASP, dotNet

Comments

Add Comment




Good luck with that

Please type the characters from the image above into the box below
or click here to get a new one


Submit