Re: Response.Redirect & Server.Execute
Re: Response.Redirect & Server.Execute
am 22.12.2007 14:25:05 von Anthony Jones
"Evertjan." wrote in message
news:Xns9A09F2572B8D7eejj99@194.109.133.242...
> Mike Brind wrote on 17 dec 2007 in
> microsoft.public.inetserver.asp.general:
>
> >
> > "Evertjan." wrote in message
> > news:Xns9A09D44AFA6B8eejj99@194.109.133.242...
> >> Mike Brind wrote on 17 dec 2007 in
> >> microsoft.public.inetserver.asp.general:
> >>
> >>> Largely correct. Except that Response.Redirect and Server.Transfer
> >>> are the two methods that "compete" with eachother in terms of what
> >>> they do. Server.Execute will cause the server to process whichever
> >>> file it is told to, but will continue to process further code on the
> >>> page after the Server.Execute call was made (unless the code in the
> >>> target file to be executed prevents that from happening eg by
> >>> including a Response.Redirect, Response.End or Server.Transfer
> >>> call).
> >>
> >> So
> >>
> >> === f1.asp ===
> >> <%
> >> Server.Transfer "f2.asp"
> >> %>
> >> ==============
> >>
> >> does effectively the same as:
> >>
> >> === f1.asp ===
> >> <%
> >> Server.Execute "f2.asp"
> >> Response.End
> >> %>
> >> ==============
> >>
> >> ?
> >>
> >> ============================
> >
> > I don't understand your question.
>
> I was just asking.
>
> > Or the point behind it.
>
> Which of the two, Mike?
>
> > Did I say
> > they were effectively the same?
> >
> >>
> >>> Server.Transfer moves the execution to a different resource
> >>> entirely, as does Response.Redirect.
> >>
> >> Not exactly.
> >>
> >> Response.Redirect
> >>
> >> just asks [in the header] the client to do a redirect,
> >> and it is up to the client to comply.
> >>
> >> Not all clients are browsers.
> >>
> >
> > OK. I'll rephrase. Server.Transfer *effectively* moves the execution
> > to a different resource entirely, as does Response.Redirect. Depending
> > on the client's ability to understand and process headers in the way
> > that you would hope that Response.Redirect will act, in an ideal world
> > where someone is accessing your web site using one of the common web
> > browsers. But don't count on it working if people are using
> > refrigerators to access your web site.
>
> Indeed refrigerators or just download the page using AJAX-technology in a
> browser, using cscript/wscript, or even using server.xmlhttp.
>
By default XMLHTTP (server or otherwise) will follow a redirect response
siliently. You can set an option on ServerXMLHTTP to disable that though.
--
Anthony Jones - MVP ASP/ASP.NET
Re: Response.Redirect & Server.Execute
am 22.12.2007 16:40:15 von exjxw.hannivoort
Anthony Jones wrote on 22 dec 2007 in
microsoft.public.inetserver.asp.general:
> By default XMLHTTP (server or otherwise) will follow a redirect
> response siliently. You can set an option on ServerXMLHTTP to disable
> that though.
>
Can you give a coded example?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Re: Response.Redirect & Server.Execute
am 26.12.2007 19:16:29 von Anthony Jones
"Evertjan." wrote in message
news:Xns9A0EA99627B99eejj99@194.109.133.242...
> Anthony Jones wrote on 22 dec 2007 in
> microsoft.public.inetserver.asp.general:
>
> > By default XMLHTTP (server or otherwise) will follow a redirect
> > response siliently. You can set an option on ServerXMLHTTP to disable
> > that though.
> >
>
> Can you give a coded example?
>
Actually what I said isn't entirely accurate. Neither XMLHTTP nor
ServerXMLHTTP gives you any choice, it will always automatically follow a
302 redirect.
Its the WinHTTP stack that underlies the ServerXMLHTTP that allows you to
disable redirects and it was that I was thinking of:-
Dim oWinHTTP
Dim oXML
Const WinHttpRequestOption_EnableRedirects = 6
Set oWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
oWinHTTP.Option(WinHttpRequestOption_EnableRedirects) = False
oWinHTTP.Open "GET", "http://server/folder/page.asp", False
oWinHTTP.Send
If oWinHTTP.Status = 200 Then
Set oXML = CreateObject("MSXML2.DOMDocument.3.0")
oXML.load oWinHTTP.responseBody
MsgBox "XML is " & Len(oXML.xml) & " characters in length"
ElseIf oWinHTTP.Status = 302 Then
MsgBox "Server Attempted Redirect to: " & _
oWinHTTP.getResponseHeader("Location")
End If
--
Anthony Jones - MVP ASP/ASP.NET
Re: Response.Redirect & Server.Execute
am 26.12.2007 21:19:07 von exjxw.hannivoort
Anthony Jones wrote on 26 dec 2007 in
microsoft.public.inetserver.asp.general:
> "Evertjan." wrote in message
> news:Xns9A0EA99627B99eejj99@194.109.133.242...
>> Anthony Jones wrote on 22 dec 2007 in
>> microsoft.public.inetserver.asp.general:
>>
>> > By default XMLHTTP (server or otherwise) will follow a redirect
>> > response siliently. You can set an option on ServerXMLHTTP to
disable
>> > that though.
>> >
>>
>> Can you give a coded example?
>>
>
> Actually what I said isn't entirely accurate. Neither XMLHTTP nor
> ServerXMLHTTP gives you any choice, it will always automatically follow
a
> 302 redirect.
>
> Its the WinHTTP stack that underlies the ServerXMLHTTP that allows you
to
> disable redirects and it was that I was thinking of:-
>
> Dim oWinHTTP
> Dim oXML
> Const WinHttpRequestOption_EnableRedirects = 6
>
> Set oWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
> oWinHTTP.Option(WinHttpRequestOption_EnableRedirects) = False
>
> oWinHTTP.Open "GET", "http://server/folder/page.asp", False
> oWinHTTP.Send
>
> If oWinHTTP.Status = 200 Then
> Set oXML = CreateObject("MSXML2.DOMDocument.3.0")
> oXML.load oWinHTTP.responseBody
> MsgBox "XML is " & Len(oXML.xml) & " characters in length"
> ElseIf oWinHTTP.Status = 302 Then
> MsgBox "Server Attempted Redirect to: " & _
> oWinHTTP.getResponseHeader("Location")
> End If
Cannot get it to work, as my
<%
server.transfer "/asp/xxx.asp"
%>
seems to return 200,
or it is xxx.asp's status 200 that is invoked anyway,
even if
oWinHTTP.Option(6) = False;
is executed [IE7 under XP].
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Re: Response.Redirect & Server.Execute
am 26.12.2007 23:39:26 von Anthony Jones
"Evertjan." wrote in message
news:Xns9A12D8DE2279Aeejj99@194.109.133.242...
> Anthony Jones wrote on 26 dec 2007 in
> microsoft.public.inetserver.asp.general:
>
> > "Evertjan." wrote in message
> > news:Xns9A0EA99627B99eejj99@194.109.133.242...
> >> Anthony Jones wrote on 22 dec 2007 in
> >> microsoft.public.inetserver.asp.general:
> >>
> >> > By default XMLHTTP (server or otherwise) will follow a redirect
> >> > response siliently. You can set an option on ServerXMLHTTP to
> disable
> >> > that though.
> >> >
> >>
> >> Can you give a coded example?
> >>
> >
> > Actually what I said isn't entirely accurate. Neither XMLHTTP nor
> > ServerXMLHTTP gives you any choice, it will always automatically follow
> a
> > 302 redirect.
> >
> > Its the WinHTTP stack that underlies the ServerXMLHTTP that allows you
> to
> > disable redirects and it was that I was thinking of:-
> >
> > Dim oWinHTTP
> > Dim oXML
> > Const WinHttpRequestOption_EnableRedirects = 6
> >
> > Set oWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
> > oWinHTTP.Option(WinHttpRequestOption_EnableRedirects) = False
> >
> > oWinHTTP.Open "GET", "http://server/folder/page.asp", False
> > oWinHTTP.Send
> >
> > If oWinHTTP.Status = 200 Then
> > Set oXML = CreateObject("MSXML2.DOMDocument.3.0")
> > oXML.load oWinHTTP.responseBody
> > MsgBox "XML is " & Len(oXML.xml) & " characters in length"
> > ElseIf oWinHTTP.Status = 302 Then
> > MsgBox "Server Attempted Redirect to: " & _
> > oWinHTTP.getResponseHeader("Location")
> > End If
>
> Cannot get it to work, as my
>
> <%
> server.transfer "/asp/xxx.asp"
> %>
>
> seems to return 200,
>
> or it is xxx.asp's status 200 that is invoked anyway,
> even if
>
> oWinHTTP.Option(6) = False;
>
> is executed [IE7 under XP].
>
It only applies when Response.Redirect is used. Server.Transfer occurs
purely on the server without roundtriping back to the client so there is now
way to intercept a Server.Transfer in client code.
--
Anthony Jones - MVP ASP/ASP.NET
Re: Response.Redirect & Server.Execute
am 27.12.2007 15:47:28 von exjxw.hannivoort
Anthony Jones wrote on 26 dec 2007 in
microsoft.public.inetserver.asp.general:
>> Cannot get it to work, as my
>>
>> <%
>> server.transfer "/asp/xxx.asp"
>> %>
>>
>> seems to return 200,
>>
>> or it is xxx.asp's status 200 that is invoked anyway,
>> even if
>>
>> oWinHTTP.Option(6) = False;
>>
>> is executed [IE7 under XP].
>>
>
> It only applies when Response.Redirect is used. Server.Transfer
> occurs purely on the server without roundtriping back to the client so
> there is now
> way to intercept a Server.Transfer in client code.
Ah, yes, my blind spot!
I'll try again.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)