Solved

Server.Transfer:  not working =((

Posted on 2000-04-13
15
1,173 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Autosum input type=text when checkbox is true 28 101
Connection String to remote Server not working 3 92
Classic ASP application Will support SQL 2014 5 93
CREATE DATABASE 3 28
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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

765 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