Question If HTML is stateless, how do web apps such as document editors (google docs, word365, etc) maintain their full dataset?

Page 3 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

sao123

Lifer
May 27, 2002
12,648
201
106
Back story... at my work, we have several large XML configuration files which associate items along with costs, which can be used when building a CADD file to take estimate the quantity of material used within the drawing to give out an estimated cost of the entire build.
One of the things we have to do frequently is update the item costs in the XML file, because construction costs (stone, concrete, blacktop, fill, etc) fluctuate almost weekly.

So I had set out to make a document editor in C# Webforms which would be used to more quickly edit the needed values, without having to scroll thousands of lines in a text editor.

Currently, I have the following functionality.
Select and Load an XML text file document.
Read and parse the document.
For Each CostRatio element or UnitCost+Unit element pair, Dynamically
Create a Label with the Material Name and CodeDesignation,
Create an Editable TextBox for Cost Ratio or 2 Editable textboxes for UnitCost and Unit,
Create A Save Button for that row.

The user could then make a change to a the values and click the button in the row which would then update the XDocument,
And eventually Save the file back into the original XML document or a new copy.

So my problem is between page load and Data Change Save, since HTML is stateless, the XDocument object does not persist between events.
Now I know I can session the document and it could be editable for a short time up to timeout... but that seems like a terrible solution.

How do document editors such as google docs and microsoft word 365 online have doucment data that persists between postbacks without maintaining an active server side connection?
WebApp Document Editors seem to have a mythical state which isnt supposed to exist...

Is there a hidden client cache control I am missing?

The operations of Document Editors seem too slow for a database, and with so many simultaneous users and documents, that would seem an impossibility?
What am I missing.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
Hidden field can be an option.

You will need to calculate how much memory the server will need though.

 
Last edited:

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
Apparently ASP.NET caching can do even more.
video 119 - 132.

==

Cache dependency on files

 
Last edited:

sao123

Lifer
May 27, 2002
12,648
201
106
Back to work on this after a long holiday weekend. The Client Cache looks the most promising, so I am going to start there. Thx.
 

Leeea

Diamond Member
Apr 3, 2020
3,617
5,363
136
Asp.net uses the Session State on the server to save data, but it times out after X minutes, so that is not reliable. It has to be somewhere on the client...

I once spun up my own version of a session object to get around it. In my typical fashion, it worked well for me, but it was a complete hash of things.

Save yourself some time and just use cookies.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
I once spun up my own version of a session object to get around it. In my typical fashion, it worked well for me, but it was a complete hash of things.

Save yourself some time and just use cookies.
Cookie maximum size is only 4K bytes, yet OP's XML docs are larger than 40K.
 

sao123

Lifer
May 27, 2002
12,648
201
106
Just to circle back to this... I tried both the Session State, and the View State, and the View states seems to be meeting my needs at this point.
The RAW XML file saved is 40K on disk, as a binary XDocument Object, it seems to work..
 

Leeea

Diamond Member
Apr 3, 2020
3,617
5,363
136
Just to circle back to this... I tried both the Session State, and the View State, and the View states seems to be meeting my needs at this point.
The RAW XML file saved is 40K on disk, as a binary XDocument Object, it seems to work..

I once did view state once for something kind of similar. In my case it was a large crystal report object. It did work, but not well. I ended up changing it to a marker pointing to a local file.


All of that data is being received and pushed back and forth for every request. In my case it was on a LAN, but it was not the best. Two/three second delay on things. Did not scale well. On the other hand it was simple and easy, which is good.


In HTML5 there is javescript feature called window.localStorage. ( https://www.w3schools.com/jsref/prop_win_localstorage.asp ). I am not sure exactly what your trying to do, but that might work better then sending the entire document back and forth on every request. You will need to write your own javascript, and it is a pain.

It is possible to get .net ajax implementation to fire custom java script events:
HTML:
    <script type="text/javascript">//<![CDATA[
        var mgr = Sys.WebForms.PageRequestManager;
        mgr.getInstance().add_pageLoaded(yourJavaScriptFunctionHere);
    //]]></script>

It includes an endRequest event for ajax post back notification.
 
Last edited:

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
I am not sure exactly what your trying to do,
OP's boss asked OP to write a web application on IIS server that can read/write files that are on the local machines.

That's why he needs to send the doc up to the server, edit it the browser and download it back.
 
Last edited: