Waste of a few days
I thought I'd post this in case it can help some poor soul out there who could potentially spend days debugging the same ASP.net problem I had...
Symptoms:
- Page loads up fine
- Page mysteriously produces a HTTP 500 Error when a control is clicked on the page.
- Page has always worked before now
- Page has a datagrid populated from a database
- No events fire on the page (or within a control on the page)
- HTTP POST status returns ERROR_INTERNET_CONNECTION_RESET when
- The post stream seems to be truncated
- Code has not changed (file has been in sourcesafe for 6 months!)
Diagnosis:
This problem is caused by the viewstate of the page (which is stored in the page) getting too big. Most HTTP proxy servers have a limit of how much data they can send back to the server in one go. Due to the ever increasing level of data in the database, the datagrid gets bigger. Because the datagrid is stored (along with all the other viewstate enabled controls in the page) in viewstate, this hidden field has also got bigger. If you sniff the http post stream, you see that the output is truncated partway through the viewstate. The server receives a truncated post stream, and in this case sends back an unhelpful message.
Solution:
Delete all your data to reduce the size of the datagrid.
However if your data is important to you or someone who pays you, the best trick is to store the viewstate on the server instead of in the page. The session variable is the best bet of course. Add these two methods to the page giving you troubles (not in any web user control(s) you may be using)
Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object
Return Session("_ViewState")
End Function
Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object)
Session("_ViewState") = viewState
End Sub
Remeber that this is a workaround that will allow the page to function. Unless you are storing session state in sql server you shouldn't use this method for all of your pages to make them smaller. The session variable is stored in server memory and this will degrade performance by filling up RAM and could result in increased hard disk writing when the server has to write to a page file to store the session state. So use carefully, especially with high volume pages...

84 Comments:
Hi, I was out blogging and found your site. It certainly got my attention and interest. I was looking for Meat information and even though this isn't a perfect match I enjoyed your site. Thanks for the read!
22 May 2006 2:24 pm
Great article! Thanks.
18 August 2007 10:36 pm
Thanks for interesting article.
19 August 2007 4:19 am
Nice! Nice site! Good resources here. I will bookmark!
10 September 2007 6:46 am
I see first time your site guys. I like you :)
10 September 2007 4:36 pm
Excellent website. Good work. Very useful. I will bookmark!
10 September 2007 6:18 pm
DhWSSg You have a talant! Write more!
31 October 2007 3:20 am
1Ri9Qn The best blog you have!
2 November 2007 4:35 pm
weZ8BA actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
3 November 2007 4:37 am
Nice Article.
3 November 2007 5:27 am
Please write anything else!
3 November 2007 6:09 am
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
3 November 2007 7:15 am
Good job!
3 November 2007 8:16 am
Good job!
3 November 2007 9:48 pm
Good job!
4 November 2007 2:26 am
Please write anything else!
4 November 2007 3:28 am
Magnific!
4 November 2007 4:27 am
gzNHnw write more, thanks.
4 November 2007 9:38 pm
Magnific!
5 November 2007 2:46 pm
Nice Article.
5 November 2007 3:20 pm
Thanks to author.
5 November 2007 5:11 pm
Hello all!
5 November 2007 5:44 pm
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
5 November 2007 6:20 pm
Wonderful blog.
5 November 2007 6:49 pm
Good job!
5 November 2007 7:19 pm
Hello all!
5 November 2007 7:50 pm
Thanks to author.
5 November 2007 8:24 pm
Thanks to author.
5 November 2007 9:06 pm
Magnific!
5 November 2007 9:46 pm
Hello all!
5 November 2007 10:19 pm
Thanks to author.
5 November 2007 10:50 pm
Change is inevitable, except from a vending machine.
5 November 2007 11:25 pm
Thanks to author.
6 November 2007 12:03 am
Energizer Bunny Arrested! Charged with battery.
6 November 2007 12:34 am
Lottery: A tax on people who are bad at math.
6 November 2007 1:32 am
Thanks to author.
6 November 2007 2:10 am
640K ought to be enough for anybody. - Bill Gates 81
6 November 2007 2:40 am
Wonderful blog.
6 November 2007 3:12 am
I'm not a complete idiot, some parts are missing!
6 November 2007 3:43 am
All generalizations are false, including this one.
6 November 2007 4:16 am
Suicidal twin kills sister by mistake!
6 November 2007 4:49 am
The gene pool could use a little chlorine.
6 November 2007 5:28 am
Thanks to author.
6 November 2007 6:10 am
If ignorance is bliss, you must be orgasmic.
6 November 2007 6:48 am
I don't suffer from insanity. I enjoy every minute of it.
6 November 2007 7:20 am
When there's a will, I want to be in it.
6 November 2007 7:53 am
Nice Article.
6 November 2007 8:23 am
C++ should have been called B
6 November 2007 8:48 am
Friends help you move. Real friends help you move bodies.
6 November 2007 9:17 am
Friends help you move. Real friends help you move bodies.
6 November 2007 9:48 am
What is a free gift ? Aren't all gifts free?
6 November 2007 10:18 am
Magnific!
6 November 2007 10:55 am
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
6 November 2007 11:27 am
The gene pool could use a little chlorine.
6 November 2007 12:05 pm
Thanks to author.
6 November 2007 12:36 pm
Build a watch in 179 easy steps - by C. Forsberg.
6 November 2007 1:07 pm
Magnific!
6 November 2007 1:39 pm
Oops. My brain just hit a bad sector.
6 November 2007 2:18 pm
640K ought to be enough for anybody. - Bill Gates 81
6 November 2007 3:03 pm
Build a watch in 179 easy steps - by C. Forsberg.
6 November 2007 3:37 pm
Wonderful blog.
6 November 2007 4:16 pm
All generalizations are false, including this one.
6 November 2007 4:53 pm
Oops. My brain just hit a bad sector.
6 November 2007 5:24 pm
Friends help you move. Real friends help you move bodies
6 November 2007 6:03 pm
Friends help you move. Real friends help you move bodies
6 November 2007 6:45 pm
Nice Article.
6 November 2007 7:29 pm
Energizer Bunny Arrested! Charged with battery.
6 November 2007 8:17 pm
Ever notice how fast Windows runs? Neither did I.
6 November 2007 9:01 pm
Calvin, we will not have an anatomically correct snowman!
6 November 2007 9:41 pm
If ignorance is bliss, you must be orgasmic.
6 November 2007 10:28 pm
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
6 November 2007 11:22 pm
Please write anything else!
7 November 2007 12:11 am
If ignorance is bliss, you must be orgasmic.
7 November 2007 12:54 am
Magnific!
7 November 2007 1:34 am
Energizer Bunny Arrested! Charged with battery.
7 November 2007 2:13 am
C++ should have been called B
7 November 2007 2:49 am
640K ought to be enough for anybody. - Bill Gates 81
7 November 2007 3:24 am
Lottery: A tax on people who are bad at math.
7 November 2007 4:08 am
Save the whales, collect the whole set
7 November 2007 4:50 am
A flashlight is a case for holding dead batteries.
7 November 2007 5:33 am
What is a free gift ? Aren't all gifts free?
7 November 2007 6:22 am
Beam me aboard, Scotty..... Sure. Will a 2x10 do?
7 November 2007 7:11 am
Magnific!
7 November 2007 7:48 am
Many individuals are concerned about becoming a victim of payday loan swindles [url=http://www.pihquickloans.co.uk/]quick loans uk[/url] quick loans You can improve the process if you know the dealer expenses or Blue Book price of the car; the top consumer location to find out real dealer value or that of a pre-owned car will probably be worth is by far Edmunds http://www.gtwtq.co.uk/
20 April 2013 8:04 pm
Post a Comment
<< Home