Great Response from Readers!
Hats off to all the great responses and discussion to this post on asp.net performance enhancements! I wanted to take some time to clarify some comments to ensure you that I am indeed not crazy ;) The unfortunate side of Blogging is that you can’t go into too much detail in certain cases, otherwise every post would take days to write and explain every angle, and cause reader’s (like you right now going, “get to the point!”) to fall asleep and tune out.
Hence we will be launching a Wiki in the next few days to go into more detail on topics, and leverage our awesome reader’s knowledge! We also have the forums up and running right now, so feel free to take your discussions there!
If you haven’t read the original article, make sure you check it out, 20 Tips to Improve ASP.net Application Performance!
Tip Number 3: Avoid Server-Side Validation
By no means am suggesting we turn off server-side validation. Some users have JavaScript turned off, and will not be able to use your site correctly if you rely heavily on JavaScript. Without Server-Side Validation, bad data can get to the server! A great approach to take here is use both. By using both, you ensure that only correct data flows into your database!
There are also certain situations where your validation requires database reads to find out if data is valid. Here of course is another ideal use of Server-Side Validation. Another side note by the way is if your database is structured correctly, it should hopefully not allow bad data to be entered into it.
The main point I was trying to make is educate a few people that purely use Server-Side Validation! Put some resources on the client, and everyone will jump for joy! If you have an application that relies on Server-Side Validation, and you add Client-Side, you will notice a dramatic speed improvement! I hope this clears it up!
Tip Number 6: Server.Transfer vs. Server.Redirect
The reality here is the article was based on “Performance”. However to dive into more details, there are actually three distinct methods of transferring data in ASP.net. Response.Redirect, Response.Transfer, and the new Cross-Page Posting available in ASP.net 2.0 and greater. All of these methods have positives and negatives. Just like most things in life, you will need to decide the best approach for your given application. Let’s take a look quickly at some of these pro’s and con’s
Response.Redirect
Without getting into to much detail, this approach is heavy and “slower” because it requires a roundtrip to the server instead of just telling the user, “Go here”. It also has restrictions on the length of your query string, and gives a lot of “visibility” to the user either in the URL
It is the simplest approach however, with the least ”hack” around needed (think back button issue that Mike Pope talked about, Thanks Mike!).
Response.Transfer
Some of you might not know this if have not completely read up on ASP.net 2.0, there are definitely some awesome improvements in 2.0! Using the new PreviousPage.FindControl, you can actually sift through the data being received. Works very well! There are some “tricks” to this approach, but I will go into it in later articles, and possibly on the Wiki.
So Response.Transfer is no question faster! It does not include the roundtrip, however, the browser thinks it is still on the same page or form, therefore, your back button wrecks havoc on this implementation, however it can be handled if your are careful/skilful. So this approach is faster, but has some issues that you should be aware of!
Cross-Page PostBacks
A new feature in ASP.net 2.0 is Cross-Page PostBacks that work really nice with forms. Just setting the button’s PostBackUrl property to the new page makes the magic happen. It’s very easy to check to see if there was data sent by checking the PreviousPage.IsCrossPagePostBack
So what do you suggest?
Use what you are most comfortable with, and what best suits your environment. However just remember that:
- Response.Redirect is slower and will show QueryString data in the URL.
- Response.Transfer is fast, however creates an “invalid” browser history.
- Cross-Page Postbacks work well, however do not work well with Server-Side only validation.
Anything else to mention on this topic? Oh yes, SEO optimization. I would use neither of these methods if I’m moving pages, servers, etc. For those cases, use a 301! What is a 301? It’s basically a way to tell search engines and other browsers that a resource has moved and the links should be updated. Using this method, you will not lose the Google Juice (mostly), and can expect search engines to update their databases in a few days!
I love how the quiet ASP.net developers pitched in and brought their valued feedback, opinions, and criticisms! That’s what the Real World is all about! Keep it coming!
If you liked this article, please share it on DZone, del.icio.us, StumbleUpon or Digg. I’d appreciate it.



