Go Premium for a chance to win a PS4. Enter to Win

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

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
0
kfehriba
Asked:
kfehriba
  • 4
  • 3
1 Solution
 
AzraSoundCommented:
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.
0
 
AzraSoundCommented:
>>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...
0
 
raizonCommented:
I agree with AzraSound.  You will find that most Companies/Sites append the GUID to the URL.
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.

 
kfehribaAuthor Commented:
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
0
 
AzraSoundCommented:
>>Is this just a problem that the server does not know how to read those headers or does the client not return those headers?

Its because the client does not return those headers.  You can send a custom header to the client, which, if programmed to do so, will respond to that header.  But the client then sends back headers to the server that it is programmed to do so, which the header you created at the server is not one of.
0
 
kfehribaAuthor Commented:
Can the client view the custom headers using java script, if so, what is the code?

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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