?
Solved

Sending custom Response Headers

Posted on 2001-06-28
11
Medium Priority
?
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 
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 1200 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

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!

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

764 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