[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Response.Redirect & Response.Buffer

Posted on 2004-09-16
11
Medium Priority
?
293 Views
Last Modified: 2008-02-01
The website I've built was created extensively with ASP javascript.  Now that I want to upload files, I've picked up a package called "Free ASP Upload" which does exactly what I want...except it's built in VBScript...for me what seems to be an advanced form of VBScript.  While I could take a few days and rewrite it into javascript, I'm sure it would take a few more days to debug it and then still not be sure I did it right.  I've thought of mixing ASP VBScript and ASP javascript routines on the same page, but that appears to be impossible.

The pages in my website all have a large header containing a chunk of html/asp/javascript.  Because of the includes and complexity, rewriting that into VBScript seems out of the question.

So I thought I'd try to build the header as usual with my ASP javascript then redirect to an asp page built with VBScript/freeASPUpload.  I added Response.Buffer=true to the first page and then do the redirect after passing through the code to build the headers.  The redirect works but I don't get the headers, only the output of the second page.

How can I get this to work?  The code looks generally like...
==============
<%@ Language = javascript%>
<!--#include file="security.asp"-->
<!--#include file="noCache.asp"-->
<%

  /******** Admin Only ********/
  if (Session("Admin")!=1){
    Session.Abandon;
    Response.redirect("login.asp");
  }
  /******** Admin Only ********/
  Response.Buffer = true;
%>
<html>

<head>
<title>Upload League Import File</title>
...
<noscript>
...
</noscript>

<%
    Response.redirect("freeASPUploadTester.asp");
%>
0
Comment
Question by:Bob3975
[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
  • 5
  • 3
  • 3
11 Comments
 
LVL 12

Expert Comment

by:GoofyDawg
ID: 12076317
Have you tried to enclose the VBScript in:

<script language="VBScript" runat="Server">
..VBSCript Code
</script>

You should be able to mix different kinds of code doing this. I did it the other way around with a VBScript ASP page, and then using some JavaScript in a separate section. Worked fine.

GoofyDawg
0
 

Author Comment

by:Bob3975
ID: 12076635
When I enclose the VBScript in:

<script language="VBScript" runat="Server">
..VBSCript Code
</script>

I get

Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
<%

It bombs as soon as it sees the asp delimeter <%
0
 
LVL 15

Accepted Solution

by:
joeposter649 earned 2000 total points
ID: 12076812
You can't do a redirect after you output html.  Basically a redirect goes back to the browser and has it request the next page.
I'm not sure what freeASPUploadTester.asp is doing but you could try using server.execute instead of redirect.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 15

Expert Comment

by:joeposter649
ID: 12076906
And here's an example of GoofyDawg's answer...

<%@ Language=javascript %>
<%  
response.Write(vbfunction());
%>  
<script language=vbscript runat=server>
function vbfunction()
      vbfunction= "this is from vbscript"
end function
</script>
0
 

Author Comment

by:Bob3975
ID: 12076962
Server.Execute !  Seems to work.  Let me make sure by getting rid of a couple of errors I'm getting.

GoofyDawg's solution will fail where indicated below
<%@ Language=javascript %>
<%  
response.Write(vbfunction());
%>  
<script language=vbscript runat=server>
function vbfunction()
    vbfunction= "this is from vbscript"
end function
<%      <----------------   fails
  vb stuff
%>
</script>
0
 

Author Comment

by:Bob3975
ID: 12077016
Server.Execute does exactly what I want.  An easy answer to a bunch of points.  But as a wise man once said,"You don't know what you don't know until you're told what you don't know."
0
 
LVL 12

Expert Comment

by:GoofyDawg
ID: 12077351
Don't use <% %>.
0
 

Author Comment

by:Bob3975
ID: 12077423
Unfortunately I believe I have to use <% %>, because of the asp statements in the VBScript such as Response.write.
0
 
LVL 12

Expert Comment

by:GoofyDawg
ID: 12077625
You're right of course, duh!
0
 
LVL 15

Expert Comment

by:joeposter649
ID: 12077684
No you don't but the order seems to be messed up...

<%@ Language=javascript %>
<%  
response.Write("javascript output<br>");
%>  
<script language=vbscript runat=server>
response.Write("script engine= " & ScriptEngine & "<br>")
</script>
0
 

Author Comment

by:Bob3975
ID: 12077788
Clearly, I stand corrected.  Learn something new everyday.  Is it the runat=server that implies this is asp and therefore no <% %> is needed?
0

Featured Post

Technology Partners: 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…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

656 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