Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sending custom Response Headers

Posted on 2001-06-28
11
Medium Priority
?
287 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

609 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