ASP.Net Post timeout
Asked Answered
S

3

8

I am stuck with asp.net post issue with last 2 weeks.

Scenario:

My application page has 3 controls. A WYSIWYG editor (Free Textbox), a text box to get name of the article being edited in WYSIWYG editor, another text box to accept key words.

Order of the controls in page from top to bottom as follows,
first, Name text box
second, WYSIWYG Editor
last, Key Word text box

Problem:

When ever users tries to save their edited documents, IIS server returns time out (Production runs on win 2008). But interestingly, "Name text" box information and half of WYSIWYG Editor (its not exactly half, it varies for each case) information is saved to database. but last "keyword text" box is not saved. During this web server hangs for a while, kicks out the user and later after few mins back to normal speed. I think app pool is recycled. But all works fine on my development environment (in My PC runs on Win 7 64bit). Also i have set ValidateRequest="False" in page directive for Production and Development environment.

Environment:

Environment .NET 4.0, ASP.NET
FreeText box WYSIWYG editor
Shared Hosting windows 2008
SQL Server 2008

Tried solutions (but no breakthrough):

Tried with Different Browser Firefox, chrome, IE and same error.
Added ValidateRequest="False" in page directive and replaced WYSIWYG editor with plain text box and tried to save, same issue.
Just tried to log the post data directly from page.request object. Still getting full data for "Name textbox" half for WYSIWYG textbox and nothing for rest.
There is no issue on DB connection or table field. I have triple checked.

Possible Suspicions and Questions:

Based on my knowledge there is no limitation on post data length. but in IIS is it possible to override this ? wondering if this is set on my shared hosting.
Basically http post data gets truncated somewhere between browser and server.request object. What would be the reason if this is happening?
If http post is truncated why whole application hangs (or restarts)?
What are the precaution need to be taken when posting html content as http post?

Thank you.

New Finding:

Checked my post using httpfox. Post size was about 9958 bytes. But firefox sends first 330 bytes of data and then web page hangs. After about a minute, i am getting NS_ERROR_NET_RESET error code in httpfox.

Checked my post using filder2 with IE9. It tries to send first 512 bytes then hangs. Returns "ReadResponse() failed: The server did not return a response for this request."

Question:

This likely would be browser issue or server issue. I think if browser issue, this wont happen for IE and Firefox.

Update:

Most likely isolated the problem towards web hosting. Tested by changing form post url to different domain and see if values can be retrieved at that domain. Yes it works. Only it didn't work for my domain. Interestingly i tested this for normal html page post. it also didnt work. So most likely a security installed to prevent this or server misconfiguration. Already put a ticket to them and waiting.

Any how all of your feed back helped me to isolate the problem.

Solved:

Yes this issue was on our web hosting site. So far i heard from them is like some firewall blocking the big post from http. They said now our domain is white listed. Anyway, now its works. But this ate 2 weeks of my time, but it was good learning experience. Thanks guys for your help. Really appreciated.

Stamm answered 27/4, 2011 at 7:9 Comment(7)
+1; Good Explaination :)Unreeve
I can't imagine you are getting the same issue if you have removed the editor. Have you tried creating a completely new project, with the text area, and ensuring that you get all content delivered? How much content are you placing in the text area?Ricer
Thanks for your reply. Yes that's puzzle me as well. initially i was suspecting the html editor. But looks like it is not. In both cases i was trying to post html formatted strings. Basically there is no limitation for the content length. But i have tested up to 4k chars. <br /><br /> I didn't try creating new project. Let me try create just a new project with same scenario and try.Stamm
what is your hosting provider ?Bespatter
@Noon Silk i tried by creating new project and test on the same server. Still i got same issue. So most likely its web-server specific issue. I have lodged a ticket to them. Thanks for your ideas on isolating this problem.Stamm
I think the moral of the story here is to have a local server to do testing on.Vasya
@Vasya I already have a local server to testing. This only happens in the production server. Local server works fine.Stamm
B
3

I have face the same error on one web page. Its was very wired because if I was use proxy, the error go way, if I was called from my computer direct I have time out, and never go on.

The site that this issue appear until now Dec/2011 is the http://www.auctionsniper.com/ The same site works if I go with the mobile version of it.

After many checks with the above site I discover that the problem was with the very big viewstate !. How I find it: I save an html part of my page, as its rendered and start remove items from the html and make post, until I discover that the post continue when I cut down the viewstate post.

The solution was to disable viewstate on many non needed controls and compress+cut in smaller part the remaining viewstate post data.

You can google and find many ways to compress and cut the view state in parts.

Some articles:

http://msdn.microsoft.com/en-us/magazine/cc188774.aspx

how to cut it tutorial:
http://www.dotnetfunda.com/articles/article634-viewstate-patterns-in-aspnet-.aspx

how to compress it
http://www.hanselman.com/blog/ZippingCompressingViewStateInASPNET.aspx
http://www.codeproject.com/KB/viewstate/ViewStateCompression.aspx
http://www.google.com/search?hl=en&safe=off&q=asp.net+compress+viewstate&aq=f&aqi=g1g-b2&aql=f&oq=

Ps: In this demo page of the free TextBox that you use, the viewstate is huge ! and its even empty from text, imagine how big the viewstate can be if you actual have and text inside. Not so free - the cost is the huge viewstate.

Follow up

As Jeyara say on the comments below, final this was the error, a blocking of large post files by a firewall on the hosting server.

So the error / timeout have to do with large post back data and its a rare but existing issue.

Backwardation answered 27/4, 2011 at 9:0 Comment(8)
Thanks Aristos. This post help me to reduce about 15K of file size using compressing and disabling view-state. But my problem still exists:-( In-fact i tried to keep whole view state in the session by overriding LoadPageStateFromPersistenceMedium and SavePageStateToPersistenceMedium Methods of base page. No Luck. PS: Regarding free textbox view state, i checked asp.net/ajax/ajaxcontroltoolkit/Samples/HTMLEditor/… this also has huge view state.Stamm
@Stamm ok, then try this:Save the source of the rendered aspx, to an html file and start delete some lines with input, until you find the one that make the trouble. All of that assume that the time out is not from the code behind. The other html editor also is not so good with this huge code behind, check the ckeditor.comBackwardation
@Stamm the main reason is the combination of some charset they cut for some reason from a router in the path. I do not know why but at my case the problem was the big length of the view state - did you cut it in smaller part under the 1k each ?Backwardation
@Backwardation Thanks for your 2 comments. Actually i have same issue when i replace WYSIWYG editor with normal multi-line text-box. So issue is not depended on WYSIWYG editor only. i changed view state size to 1kb as well. No Luck.Stamm
@Stamm Please try the procedure I suggest:Save the source of the rendered aspx, to an html file and start delete some lines with input, until you find the one that make the trouble. All of that assume that the time out is not from the code behind. Finally after you find where its stops, the problem is on your modem/router and you probably fix it if you buy a new one. When a modem after years have problems, then issues like this appears. I have personal experience.Backwardation
@Backwardation thanks for your suggestion. With all of your help, managed to isolate the issue towards, web hosting. Looks like they have some firewall to block bigger post. Now our hosting company fixed it. Now works.Stamm
@Stamm I am glad to help you solve your problem, if you vote and accept the answer you make me glad a little more.Backwardation
@Backwardation i mark your answer as correct, which helped me to narrow down the issue further. cheers.Stamm
V
2

Have you looked at whats being posted back?

Try something like Fiddler2 to view the postback.

You may find that something is being truncated at the browser.

The RichText area may also be limited by the number of chars it will post back.

Vasya answered 27/4, 2011 at 10:15 Comment(2)
Thanks Dreaddan for your suggestion. I didnt try with fiddler, but i tried with httpfox. I guess both does the same job. new interesting finding i have found. My page is about 8878 bytes, but firefox sends first 345 out of 8878 and then hangs. After about a minute it returns NS_ERROR_NET_RESET. Any idea?Stamm
I would say that points at the webserver or if theres other other issues with that box possably a dodgy network switch( but thats for another site) I would recomend trying it using another server, even if it's on a desktop.Vasya
D
1

Try this, In your web.config , add the following

      <httpRuntime maxRequestLength="8096"/>

somewhere in <system.web> tag, since the default request length is 8096, your postdata might be greater than that, so add it with a bigger value than i provided. Hope this shall help.

Denise answered 28/4, 2011 at 5:47 Comment(1)
Thanks for your reply. Its already increased to 4MB. maxRequestLength="4194300". Our application have a feature to upload profile picture, so this would allow users to upload about 4MB.Stamm

© 2022 - 2024 — McMap. All rights reserved.