Solved

Sending custom Response Headers

Posted on 2001-06-28
11
278 Views
Last Modified: 2008-02-01
I need to send the following response from my ASP page:

HTTP/1.0 302 Redirection
Set-Cookie: WebMailID=3B3B7624; Path=/
Cache-control: no-cache="set-cookie"
Cache-control: private
Content-Length: 0
Location: http://www.sm.gordon.edu/MBX/garth/ID=3B3B7625 

I don't want the server to send anyting else.  I've got the whole thing in one string and the lines are separated by Chr(10)'s.
0
Comment
Question by:garthmiller
  • 6
  • 5
11 Comments
 
LVL 7

Expert Comment

by:John844
ID: 6235518
are you using

Response.AddHeader

show the code..
0
 

Author Comment

by:garthmiller
ID: 6235540
I don't know what I should use.  I went through a lot of code to get this string back from another server.

<%
'Lots of code here

strREDIRECT = socket.Buffer
%>

After this strREDIRECT contains all of the lines I listed before.
0
 
LVL 7

Expert Comment

by:John844
ID: 6235562
here are a few ideas if you are not using them  
you might be able to use response.redirect as well


<%@ Language=VBScript %>
<%
Response.Buffer = true
Response.Clear
Response.AddHeader "HTTP/1.0 302", "Redirection"
'Response.AddHeader "Set-Cookie: WebMailID=3B3B7624; Path=/
Response.Cookies("WebMailID") = "3B3B7624"
Response.CacheControl = "no-cache"
Response.AddHeader "cache-control","private"
Response.AddHeader "Content-Length", "0"
'Response.AddHeader "Cache-control": no-cache="set-cookie"
Response.AddHeader "Location", "http://www.sm.gordon.edu/MBX/garth/ID=3B3B7625"

Response.End
%>
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 7

Expert Comment

by:John844
ID: 6235571
dont understand the question.  you might want to rephrase it.  do you mean that you have the string of 6 items like
HTTP/1.0 302 Redirection<chr(10)>Set-Cookie: WebMailID=3B3B7624; Path=/<chr(10)>Cache-control: no-cache="set-cookie"<chr(10)>Cache-control: private
Content-Length: 0<chr(10)>Location: http://www.sm.gordon.edu/MBX/garth/ID=3B3B7625

seperated with chr(10) and you want to display them like

HTTP/1.0 302 Redirection
Set-Cookie: WebMailID=3B3B7624; Path=/
Cache-control: no-cache="set-cookie"
Cache-control: private
Content-Length: 0
Location: http://www.sm.gordon.edu/MBX/garth/ID=3B3B7625 
0
 
LVL 7

Expert Comment

by:John844
ID: 6235580
if that is what you have, then use something like:

dim aryString
aryString = split(strREDIRECT,chr(10))

dim i
for i = lbound(aryString,1) to ubound(aryString,1)
  response.write aryString(i) & "<BR>" & vbCrLf
next
0
 

Author Comment

by:garthmiller
ID: 6235595
I have all the items in one long string like:

HTTP/1.0 302 Redirection<chr(10)>Set-Cookie: WebMailID=3B3B7624; Path=/<chr(10)>Cache-control: no-cache="set-cookie"<chr(10)>Cache-control:
private<chr(10)>Content-Length: 0<chr(10)>Location: http://www.sm.gordon.edu/MBX/garth/ID=3B3B7625
0
 
LVL 7

Expert Comment

by:John844
ID: 6235630
here, try this:

<%@ Language=VBScript %>
<%
dim strRedirect
strRedirect = "HTTP/1.0 302 Redirection" & chr(10) & "Set-Cookie: WebMailID=3B3B7624; Path=/" & chr(10) & "Cache-control: no-cache=""set-cookie""" & chr(10) & "Cache-control: private" & chr(10) & "Content-Length: 0" & chr(10) & "Location: http://www.sm.gordon.edu/MBX/garth/ID=3B3B7625"

dim aryString
aryString = split(strREDIRECT,chr(10))

dim i
for i = lbound(aryString,1) to ubound(aryString,1)
 response.write aryString(i) & "<BR>" & vbCrLf
next




%>
0
 

Author Comment

by:garthmiller
ID: 6235711
Ok, here is what I've got:

<%
     'Send Redirect response to client
     Response.Buffer = true
     Response.Clear          
     Response.AddHeader "HTTP/1.0 302", "Redirection"
     Response.AddHeader "Set-Cookie", "WebMailID=" & strWebMailID & "; Path=/"
     Response.AddHeader "Cache-control","no-cache=""set-cookie"""
     Response.AddHeader "Cache-control","private"
     Response.AddHeader "Content-Length", "0"
     Response.AddHeader "Location", strLocation
     Response.Flush
%>

I'm not sure if this is sending the right thing to my browser though.  Will it be redirected?  Will it have a cookie set for WebMailID?
0
 

Author Comment

by:garthmiller
ID: 6235776
After I execute the code above, I view the source in my browser and this is what I see:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type></HEAD>
<BODY></BODY></HTML>

I don't want the server to send all this stuff!
0
 
LVL 7

Accepted Solution

by:
John844 earned 300 total points
ID: 6235885
you can try this:  I am assuming that the first item in list will be the http...redirection and the last item in list will be the location

<%@ Language=VBScript %>
<%
dim strRedirect
strRedirect = "HTTP/1.0 302 Redirection" & chr(10) & "Set-Cookie: WebMailID=3B3B7624; Path=/" & chr(10) & "Cache-control: no-cache=""set-cookie""" & chr(10) & "Cache-control: private" & chr(10) & "Content-Length: 0" & chr(10) & "Location: http://www.sm.gordon.edu/MBX/garth/ID=3B3B7625"

dim aryString
aryString = split(strREDIRECT,chr(10))
dim aryTemp

dim i
for i = lbound(aryString,1) to ubound(aryString,1)
     'response.write aryString(i) & "<BR>" & vbCrLf
     aryTemp = split(aryString(i),":")
     'ignore first and last because they have redirection in them
     if i = lbound(aryString,1) or i = ubound(aryString,1) then
     else
          if ubound(aryTemp,1) > 0 then
               'Response.Write aryTemp(0) & " ### " & aryTemp(1) & "<BR>"
               Response.AddHeader aryTemp(0),aryTemp(1)
          else
               'Response.Write aryTemp(0) & " ### " & "<BR>"
               Response.AddHeader aryTemp(0),""
          end if
     end if
next
'Response.write "redirect to " & mid(aryString(ubound(aryString,1)),11)
Response.redirect mid(aryString(ubound(aryString,1)),11)


%>
0
 

Author Comment

by:garthmiller
ID: 6237979
Great answer. Thank you very much!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question