Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

Using stateserver to store global variables

Hi,

I have a web that is running on 2 servers with IIS6 and webfarm.
I'm using a stateserver to store the sessions. My question is:
Is there a way to use a stateserver to store global variables?

What I was thinking was something like communicating directly with the stateserver to set and retreve data or maybe use the .net sessions to do it with a constant sessionid.

Regards,
├×orgeir
0
poxy
Asked:
poxy
  • 5
  • 4
  • 2
1 Solution
 
Thandava VallepalliCommented:
You can use Application to save the global variables.....

0
 
poxyAuthor Commented:
quote : "Application state variables are, in effect, global variables for each ASP.NET application."

I need them to be shared across servers and applications.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
This is not available in .Net. Application varables will not be shared among applications, nor will they be shared among different servers on the same webfarm.

You should use a database for central settings that might change often or a Database or XML file for static configuration data.

Optionally you could use a serveractivated remoting object, but the database is probably an easier and more scalable solution
0
 
poxyAuthor Commented:
Well.. not exactly what I was looking for..
0
 
Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
Sorry, but it's the only thing available to you unless you implement your own state service
0
 
poxyAuthor Commented:
Well.. i got my self a packet sniffer and sniffed the commication between the asp.net and the stateserver. And found out that it is prety simple. Then I found a telnet class and succefully stored my own global variable in the stateserver. So that was what I was looking for. But you got the point for being closest.
Best regards, Thorgeir
0
 
Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
Any chance you could share that code?
0
 
poxyAuthor Commented:
Sure:
----------------------------------------
Innn.Lisa.Misc.TelnetClient telnet = new Innn.Lisa.Misc.TelnetClient("213.176.158.9",42424,2);

telnet.Connect();

string command = "PUT //LM/W3SVC/1/Root(Mb1OOYGzF/lgC6PvuXxHDJHt5lc=)/uutcvk552h51wz55203p5nmo HTTP/1.1\r\n";
command += "Host: 213.176.158.9\r\n";
command += "Timeout:60\r\n";
command += "Content-Length:3\r\n";
command += "\r\n";
command += "123";
command += "\r\n\r\n";

telnet.SendMessage(command);

//telnet.SendMessage("GET //LM/W3SVC/1/Root/lisa(syXS+0BN87ddXql4EvLGmiLYco8=)/5p2v1l450iuc3hzj1phi4hbk HTTP/1.1\r\n\r\n",true);
//Response.Write(telnet.WaitFor("200 OK","\n"));
//Response.Write(telnet.WaitFor(2));

telnet.Disconnect();
--------------------------------------------------------------

the sessionid is this : 5p2v1l450iuc3hzj1phi4hbk
and this is some sessionid hash : syXS+0BN87ddXql4EvLGmiLYco8=

I have yet to figure out how I can generate this hash but I thik it's ok to use some old sessionid & hash.
You can test this out by using the windows telnet client and past the commands in it.
0
 
poxyAuthor Commented:
blah.. in the code I sent there are different sessionids and hash in the PUT and GET strings. But it should be the same.
0
 
Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
Thanx!

The hash seems to be a base64 encoded string. It can probably be any text generated at startup of the application, or fixed in the application_start
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now