Search code examples
asp.net-mvc-3page-caching

StackOverflow's Ask Form mechanism?


We all see,

When we are in process of writing a question on StackOverflow, before we post our question. If we close the browser or refresh it, we can still see that, all the content we typed in form is still available.

How is it programmed.

I want to do something similar in my application.

I can think of storing two session variables

  1. Title - Question
  2. Body - message

Update the session variables at minimum time Intervals and kill the variables on click of "Post your Question" Button

I am Not positive if this is how StackOverflow is handling this.

Can any one suggest best approach?

My platform is ASP.Net C# MVC 3.0


Solution

  • The best way to see how does it work is use the browser with some inspector for an example Firefox + Firebug.

    You will see, that the page is posting content of the answer field from time to time and saves it on the server with ajax calls (therefore it also sometimes displays "draft saved" message while typing).

    There are also other connections in the background: for an example websockets, which causes that the site really is updated on-life.