Quick ASP.Net tip: Half your page size in ASP.Net instantly
Ok it might be a little less than half side but it's near enough. I've been sitting on this for a while and needed to reference it for someone so I thought I'd post quickly about it. One of the most common complaints about .Net is that you have a lot of hidden "content" by the way of hidden inputs and the likes throughout your site. This can easily get corrupt on postback/slowdown the page load times etc.
Really you should be optimising each control on the page (enabling/disabling where relevant) but if you want to cheat (lets face it, we all do):
- Download the files: PageStateAdapterv1.0.zip (3KB)
- Put PageStateAdapter.browser into your /App_Browsers/ folder (or create one and add it)
- Put TSDPageStateAdapter.dll into your website's /bin/ folder
- Load up your website and checkout your ViewState :)
Incase you're interested in the source for it:
PageStateAdapter.browser










PageStateAdapter.cs












The best example of how much this reduces ViewState by is when you add a large DataGrid to your site.
Post files: PageStateAdapterv1.0.zip (3KB)
Update: Apologies to those of you who downloaded and found it wouldn't compile, the .browser file was a little off (missing the second "PageStateAdapter"). I've updated it and changed the zip file download. Enjoy!
Liked this post? Got a suggestion? Leave a comment