Max size of HTML hidden variable?

What’s the maximum size in bytes or charactors of an HTML hidden variable?

There’s no limit in the standard. “As much as your server and/or browser can transfer without having problems” is the answer - tens of megabytes, certainly.

Great, it gonna be a little strange, I’m going to have to store strings maybe upto 1000 characters, so that won’t be a problem.

Thanks

I’ve seen instances where people have misused the viewstate in ASP.Net and ended up with hidden variables with hundreds of kilobytes of encoded information in them.

It still worked OK, but it does slow down the requests since all that information has to be posted up to the server (particularly if your client is using ADSL with a slower upload speed).

A few thousand characters shouldn’t be a problem if you’re POSTing the data back. In practice GET requests can get truncated (depending on browser, server etc) at large sizes (the classic one being 2038 characters in IE4). A POST method should have no such problems.

I’ll be stunned if this ever get’s over a few k. This is an intranet only mapping app.

I need the users to be able to store there current view state and reload it. I’ll store it in XML.

It will include map basics like xy coordinates, layers on off, and text that has been stored with the map. The user text will need to store xy coordinates as well, perhaps font and color and all that other crap too.

I’m just a little bit worried about painting myself into a corner with hidden variables.

But. This is not meant to be a main mapping program (we have that). It’s meant to be used as a quick and dirty ‘I need it, I want to save it and get it back’.

Perhaps a couple of thousand bytes of XML.

Thanks

enipla,

IIRC, you’re doing this in .NET.

It can be a lot more efficient for you to put the data values you want to store in to a StringDictionary or HashTable and just add that as an entry into the built-in ViewState object, versus creating a hidden variable and assigning its value to be your XML object.

The worst of all worlds would be to build your own XML object and then dump that in ViewState, it’ll end up about twice as big as it needs to be as it encodes all the xml overhead twice.

As others have said, for a few K it doesn’t much matter, but those are the kinds of design decisions that get embedded deeply and don’t get changed when the app is slowly morphed until it’s got 150K of hidden vars.

The other upside to viewstate over a hidden var is viewstate isn’t subject to user tampering. On an intranet app that isn’t as serious a threat, but I happen to have worked on several GIS-related apps that started out intranet until somebody got the idea to expose them to the public for self-serve zoning lookup, etc.

So you can’t safely assume a benign user community for the life of your app. Probably yes, but not guaranteed.

Thanks LSLGuy.

What was that sound……[sub]damn national guard is playing with their 5-16s again whoooosssss…[/sub] Wait…. ViewState object….is the ViewState object server side? Will it hold XML? It’s persistant for different calls from thousands/millons of different clients?

That can’t be, so the ViewState object must be client side.

Will a ViewState object on the server hold this info for any client? Can a client come back and get his view state at any time during a session? That would be fantastic. Sounds like a lot of overhead on the server though.

No. We don’t understand each other.

When I need to save a file on the client as an XML file, it still needs to be thrown at the server to do so. The server CAN write to the client. The client (through a browser) can’t write/save to itself. I guess it’s a security issue.

Can a “StringDictionary or HashTable” be stored on the client?

Ehh?

Example -

Client is browsing along, building XML as it goes and sends it to the server.

Client stores the XML in jScript or hidden HTML vars. (Hidden is the only way I’ve be able to get this to work)

Server builds .gifs and sends them back to the client.

Client wants to save there current coordinates (and other stuff such as text, it’s all XML) and be able to reproduce the exact same map. On their next session. Perhaps 2 months from now.

Client can’t write files to itself.

Sever can write to the client.

Client asks for a save. Client Sends local XML text to server (from the hidden vars on client). Server bundles into file and sends file back to client as a save as…What the client names it.

When I need to save a file on the client as an XML file, it still needs to be thrown at the server to do so. The server CAN write to the client. The client (through a browser) can’t write/save to itself. I guess it’s a security issue.

Can a “StringDictionary or HashTable” be stored on the client?

Ehh?

Example -

Client is browsing along, building XML as it goes and sends it to the server.

Client stores the XML in jScript or hidden HTML vars. (Hidden is the only way I’ve be able to get this to work)

Server builds .gifs and sends them back to the client.

Client wants to save there current coordinates (and other stuff such as text, it’s all XML) and be able to reproduce the exact same map.

Client can’t write files to itself.

Sever can write to the client.

Client asks for a save. Client Sends local XML text to server (from the hidden vars on client). Server bundles into file and sends file back to client as a save as…What the client names it.

I need to store this info on the client. As a file. I need to be able to write to the client. The client can’t write to itself. The server can. I take the info stored on the client, send it to the server and it does a resonse.write (or whatever it is) pops the save dialog on the client and the client can save the file

AFAIK the server can’t store the information for all individual clients. Unless the ViewState object can do it. Or I could dump it into a database, but that seems a bit overboard. And then I would have to look at randomizing file names and stuff. No thanks.

I was wondering about the size of the HTML hidden vars because I really don’t seem to have any where else to put the XML (before the user calls for a save).

Yes, I’m way in over my head.

And I’ve been a licences SCUBA diver for 30 years.

I’ve been down to 140’. Blue Hole. But it’s nothing like the .NET GIS IMS development I’ve been trying to do.