views:

1177

answers:

3

Hello,

I've created an IHttpHandler in .NET C# which returns pieces of html to a classic asp page.

The classic asp page communicates with the IHttpHandler through basic http requests using ServerXMLHTTP in vbscript or Ajax Calls in JavaScript.

Now, I need a way to share a variable which I have in vbscript but not in javascript with the .NET application.

The first bit, sharing a variable between classic asp and .net is not a problem as I can just add it onto the http request. Because the variable is not available in javascript however I can't do this in that case.

I had the idea that I could maybe cache the variable in the .NET application and use the cached version for javascript calls. But for this to work I would need a way to uniquely identify the "client" in .NET...

I tried to add System.Web.SessionState.IRequiresSessionState to my HttpHandler and use the SessionId but this didn't work because every single call to the HttpHandler seems to get a new ID.

Am I thinking the right way? What are my options here?

A: 

How about having a hidden variable on the page in which you can store the value of the variable from your server side vb script of your asp pages.

Then you can use Javascript to query this variable to send across to the Asp.Net handler through your ajax calls.

Vaibhav
Hm, I should have mentioned that if possible I'd like to avoid printing out the variable on the page...
Ben
+2  A: 

You could put your value in a cookie, then you could read with javascript and do anything with it, including sending it in a request to the .net app...

Mauricio Scheffer
A: 

In the end my solution to the problem was the following:

  1. I send the variables to my webservice along with the normal ws request
  2. I store the variable values in a hash table on the webservice and return the hashkey to the client in a hidden html object (I used a head <meta> element for that)
  3. In the javascript I read that hash value and attach it to the http-request as a header value.
  4. When the webservice sees that hashkey he looks up the respective variable values in the persistent hash table.

Might not be the very best solution but seems to work well in my case...

Ben