0

Just wondering what limitations there are in ASP doing a Server.Transfer two levels? So a page transferring to another page that then transfers to one more page.

Here is our current setup. In an attempt to please SEO, we have created "fake" URLs containing keywords. We then have a 404 error handler (IIS) picking these up, redirecting to another ASP page which pulls out some key information from the URL, and does a Server.Transfer to our "real" page. For reasons outside the scope of this post, it is required that I make a further Server.Transfer from this page. The page we are now on needs to set the page title.

Is this possible?

Sami.C
  • 561
  • 1
  • 11
  • 24

1 Answers1

1

What you want is certainly possible.

Sure, there are some limitations... but, the limitations are not on the number of server transfers which you plan to daisy chain... Just make sure you don't end up creating a vicious cycle :)

the limitation is as follows; server.transfer ( and server.execute too for that matter ) cannot access the previous page's variable context.

so if you set a variable say Age=50 in page1 and page1 does a server.transfer to page2, do not expect page2 to know anything about that Age variable declared & set by the page1. In fact, you can even Dim the same variable (Age) in page2, you won't get an error. This is because, neither the .transfer'ed, nor the .execute'd pages work like the [!--include...] files...

So what to do? How do you share information among those pages that you plan to daisy chain using server.transfer? The answer is to use session variables!. That's one effective way.. ( of course you may go out of your way to write to db or text files, but why? )

The only the other thing that your page2, and page3 could share from the the original page1 is the querystring, and post & cookie data! Those request collections will still be available in the transferred ( or executed ) pages.. This means that you can do request("age") in both page2 and page3 if the original page ( page1) was hit as page1.asp?age=99

anyway, coming back to your org. question... what you want is certainly doable...
just don't set any variables in page1, simply work with session variables...

and don't forget to clean up the session vars when you are done on the final page.

hope this helps you...

Average Joe
  • 4,521
  • 9
  • 53
  • 81
  • thanks mate, think I may not have given a completely accurate explanation of what am I trying to do, but nevertheless I figured it out :D – Sami.C Feb 12 '12 at 03:58