Solved

Server.Transfer:  not working =((

Posted on 2000-04-13
15
1,167 Views
Last Modified: 2012-06-27
Ok. check this out.
simple question.

I try this...

Server.Transfer("/_common/error.asp" )

Works 100% fine.

Now... when i add some VARIABLES

Server.Transfer( "/_common/error.asp?strError=" & strError )

or ANYTHING with a & (even just this...Server.Transfer("/_common/error.asp&") and / or some stuff after.. no luck.

i get this error.
The call to Server.Transfer failed while loading the page.

or

Invalid URL form or fully-qualified absolute URL was used. Use relative URLs.


WHAT's GOING ON HERE?!?!?!?!?

-PK-
0
Comment
Question by:pure032398
  • 5
  • 4
  • 3
  • +2
15 Comments
 
LVL 2

Expert Comment

by:MoMarvi
ID: 2712887


what about

strTemp = "/_common/error.asp?strError=" & strError
Server.Transfer(strTemp)

0
 
LVL 1

Author Comment

by:pure032398
ID: 2712990
Same error.

Invalid URL form or fully-qualified absolute URL was used. Use relative URLs.
0
 
LVL 2

Expert Comment

by:MoMarvi
ID: 2713147
I have a hunch that you cannot use variables in the Server.Transfer method, since the does transfer the request.querystring or request.form of the parent pages.

If strError is generated as

strError = Request.QueryString("Error")

you'll probably have to get the value in the transfered page the same way.

Only a SWAG.


0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 1

Expert Comment

by:jbilsten
ID: 2713206
Could you use a Response.Redirect("/_common/error.asp?strError=" & strError) instead of Server.Transfer?
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 50 total points
ID: 2713265
Use session variables.

Page1.asp
session("strError") = "whatever"
server.transfer "page2.asp"


page2.asp
response.write session("strError")

Server.Transfer wasn't designed to be used in the way you're trying to use it.  As MoMarvi indicated the request object isn't repopulated via a server.transfer.  The idea is: that it's a single request, being handled by multiple ASP scripts.  So the ASP objects are static.  Trying to add a querystring would be like making multiple requests (a redirect).
0
 
LVL 2

Expert Comment

by:burntout
ID: 2713971
you might try putting the URL in a variable, and doing a Server.URLEncode() on it befor the transfer.
0
 
LVL 1

Author Comment

by:pure032398
ID: 2715027
jbilsten:

Yes. that's what i'm doing now. BUT, the advantage of S.T is that it doesn't make a return request to the client, therefore speeding up transactions, blah blah blah .....


clockwatcher:

  Yeah. I could try doing that, but that sorta means i'm going to have to go over lost of my code, making more changes. So i don't want to do that, when response.write can handle it ok, currently.


burntout:

Nop. didn't work either
Server.Transfer Server.URLEncode( "shoppingCartPurchaseFailure.asp?intError=1&" & strCCDetails )
resulted in

The call to Server.Transfer failed while loading the page.


I'll give the points to clockwatcher.

Which is depressing, becuase there is no Server.Transfer function, where u can pass it a querystring.

*DAMN!*

-PK-
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 2715110
Actually, you may want to try URL encoding the thing again.

I don't think it will work any better, but the sample you posted definitely wouldn't work right.  You don't want to urlencode the whole thing only the variables within the querystring that may cause problems (strings for example).  URLEncoding the whole thing is definitely going to give you a messed up URL.

Try:

Server.Transfer "shoppingCartPurchaseFailure.asp?intError=1&strError=" & server.urlencode(strError)
0
 
LVL 1

Author Comment

by:pure032398
ID: 2715216
hmmm i'm not sure that will work either, becuase if i do this...

server.transfer "xxx.asp?"

i get the error.

so i assumed ANYTHING with a querystring will get me an error. i'll still give it a go and confirm this...

-PK-
0
 
LVL 2

Expert Comment

by:burntout
ID: 2715365
Hey I was just looking through an ASP book, and it says that the reason you cant use querystrings is because you don't need to.  when you transfer all of your variables are still available.

so if you were going to do something like this

Server.Transfer "file.asp?name=" & Name

you could just transfer and the value of Name should still be there.
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 2715389
burntout,

That's what MoMarvi and I already said.  The Request objects aren't repopulated; they're static-- they don't change from the initial request.

I assumed pure is trying to ADD new information to the request-- to indicate an error condition within a currently executing page and pass that error on into a generic error-handler via Server.Transfer.  Server.Transfer isn't designed to be used as if it's handling a new request.  It's designed with the one request, multiple chained ASP scripts in mind.
0
 
LVL 2

Expert Comment

by:burntout
ID: 2715470
opps, sorry about that..
0
 
LVL 1

Author Comment

by:pure032398
ID: 2718354
hehehe

I was trying to Add new information to the request, just like you thought Clockwatcher, so what do i do ???

If ... = 1 Then
intError = 1
                  'Server.Transfer "shoppingCartPurchaseFailure.asp?intError=1&" & strCCDetails
                  Server.Transfer "shoppingCartPurchaseFailure.asp"

<next page>

if intError=1 Then .....

Not a problem =)

-PK-
0
 
LVL 1

Author Comment

by:pure032398
ID: 2718359
Actually, i was wrong. =(
Sorry. Forget what i just said.

intError didn't get populated on the next page....

weird...

??
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 2718556
You have to use session variables.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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 information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

777 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