Link to home
Start Free TrialLog in
Avatar of kfehriba
kfehriba

asked on

Response.AddHeader

The Response object supports AddHeader which is suppose to add a custom header to the page that is being sent to the client.

To read that header in the Request Object you just read it as a server variable with the HTTP prefix.
 
What I am trying to do is to be able to set a guid as a header then read it whenever the page makes another call to the server. This is to avoid the use of the IIS sessions without having to append a guid as part of the form being submitted or querystring for all links on every page.
 
So the design would be:
 
A person requests a page.
As the page is being created a custom header is added (Response.AddHeader("GUID",strSessionGUID)
The person views the page then clicks on a link or submits a form.
The request is processed and I grab the custom header (Request.ServerVariables("HTTP_GUID")) to find out what their session guid.

Can this be done? Most of my research points to no, but that is why I turn to all of you. If not, what is another way to pass a guid to the client and back to the server without using cookies and without having to add the information to every link and form submission?

Thanks,

Kent
Avatar of AzraSound
AzraSound
Flag of United States of America image

The ServerVariables collection of the Request object contains only those headers sent from the client to the server, and since the header created via the AddHeader method is done at the server, it is lost, unless it is also defined at the client, when you attempt to request it on your next page.  Its just not part of the ServerVariables collection.
>>what is another way to pass a guid to the client and back to the server

There are really only 3 ways, and commercial products that emulate the Session object all use one of these:

1) Cookies/Built-in Session Object
2) Append GUID to every URL
3) Write GUID to hidden input element on every page


Even the Cookie Munger from MS resorted to appending the GUID to the URL.  Of course, I'd be more than happy to be proven wrong...
Avatar of raizon
raizon

I agree with AzraSound.  You will find that most Companies/Sites append the GUID to the URL.
Avatar of kfehriba

ASKER

Azra,

You state, "since the header created via the AddHeader method is done at the server, it is lost". But it isn't 'lost' at the server is it? I thought that it is sent to the client. And the client does have the capability of returining headers to the server? Is this just a problem that the server does not know how to read those headers or does the client not return those headers?

Kent
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can the client view the custom headers using java script, if so, what is the code?

Kent
To be honest, I have no idea.  Perhaps you can post a question asking this in the Javascript topic area.
Thanks for the input.