Avoid unnecessary processing
You don't want to spend a lot of CPU cycles doing work that isn't needed. Here are some ways to avoid that:
Validate early. Make sure you have all the data you need in the correct form before spending resources processing the data. If you're going to fail, fail early.
Check whether the visitor is still connected before doing expensive processing. You can do this by checking
Response.IsClientConnected
.Check
Page.IsPostBack
, so that you won't regenerate data that you already have inViewState
.