0

I want to display appropriate error message when a connection is lost with a server. During a GET request the browsers "Connection Lost" message is displayed but when a POST request is made and no response is displayed the page doesn't respond properly. I am developing the page in ASP.net

Hope to hear fast responses.

Thanks in advance.

altsyset
  • 339
  • 2
  • 20

1 Answers1

1

HTTP is not designed to be connected, it is stateless. before ASP.NET SingnalR was born, everything is just request-response. No matter GET or POST, the server should always send response to the client.

A "failed" post, should also be responded but with a status code like 500. In your case, you want to detect if a network connection is cut off, so the "failed" will mean "timeout" for you.

From server side, you cannot control it. So you can only do it on client side. such as using JavaScript to send a POST request, and if the server did not response in 15s, you can call it "connection lost", and display a message on your webpage.

Facebook chatting window is using this way. It will have a javascript function running on client browser, and keep "ping" the server to tell if the connection is OK.

Edi Wang
  • 3,547
  • 6
  • 33
  • 51
  • Now you have cleared what i am supposed to look for and I found this: http://stackoverflow.com/questions/1018705/how-to-detect-timeout-on-an-ajax-xmlhttprequest-call-in-the-browser So thnx alot – altsyset Jan 14 '13 at 09:57