Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

server.transfer question

Status
Not open for further replies.

way2many

Technical User
Nov 28, 2003
139
US
Hi,
I'd like to use server.transfer to re-direct users to different pages but I'm getting an error if I use page name with parameters:

dim path_transfer
path_transfer="_TileArticles.asp?ArticleID=" & ArticleID
server.transfer ("path_transfer")

Error Type:
Server object, ASP 0230 (0x80004005)
The call to Server.Transfer failed while loading the page.
/404.asp, line 39

it works fine with pages that don't use parameters:
Server.Transfer ("Help.asp")

Can server.transfer work with parameters or I'd better use response.redirect?

Thank you
 
Server.Transfer doesn't allow parameters because it's not really a URL that you're transferring to, it's a file.

Note, though, that the current context is automatically transferred to the new page. That means that the Request object, the Session object, the Application object (even if you change applications), the current Response object (anything you've "written" so far) are all transferred to the new page.

Odds are you won't need to pass any parameters.
 
To clarify: script variable aren't transferred this way, though. If you need to transfer some kind of script variable (let's say you looked up some info in a database before performing the transfer) then you'll need to place it in the Session object, or failing that (if you're not using sessions and don't want to), use Response.Redirect. The latter solution, though, carries the overhead of a round trip to the user and usually won't be followed by search engines.
 
Thanks for responding so fast.

I'm trying to build search engines friendly website with 404.asp file doing redirections.

Will it be OK for Search Engines if I'll have my links like:
CeramicDecorativeTile_T40-698.htm

on error 404 my 404.asp page will extract prod. number and assemble the correct URL like:
CeramicTile.asp?prodID=T40-698

and either response.redirect to this address or use server.execute

I've read that many web sites use similar techniques but I'm not sure what is the best method of avoiding "?" in the query string.

Thanks
 
If you use Response.Redirect then you're sending a message back to the browser that says "go to this page instead of the one you were trying to get," something that search engines tend to hate. It doesn't matter what the actual URL looks like, whether it has a "?" or not: if you send a redirect then you've probably lost the search engine.

If you just use Server.Execute("yourcorrectpage.asp") without a query string, you should still be able to reference Request.QueryString in the new page... you can safely strip it out of the page they were requesting (just use the part before the "?") because it will magically be there on the new page -- note that the URL won't change for the user.
 
Genimuse,
I didn't understand the second part about Server.Execute

I was under impression that Server.Execute works like file include.
I have a fake page address.
On err 404 my 404.asp page constructs the correct URL and Server.Execute ("page.asp?prodID=" & prodID) would insert this page into 404.asp page

Search engine will think that this is the page that it requested.

I'm not sure why you are suggesting to use Server.Execute without query string.
Would you explain it, please.

Thank you
 
Sorry, I meant Server.Transfer, not Server.Execute. You are correct about Server.Execute, and it'd definitely not what I meant.

If you use Server.Transfer without a querystring then the original querystring that called your first page will be passed to the .Transferred page.

Make sense?
 
actually the search engine crawler will see the 404 error, mark the URL as missing and not even index the page.
to use SE crawler safe redirects you need to send a 301 status before the redirect.

Code:
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently" 
Response.AddHeader "Location", "NewUrl"
response.end
%>

custom 404 scripts are perfect for visitors, but should only be used as intended.
a fall back for an out of date SE index where the page has been removed. When the SE crawler gets a few 404's for a page url it will be removed from the index.

maybe what you actually need to use is an URLRewrite component so you can use "Spider Safe URLs", depending of course on how much control you have on the server.


Open Source Component



Chris.

Indifference will be the downfall of mankind, but who cares?
 
Mmm, good point, even with a Server.Transfer the header will still contain the 404.

Will the page still send a 404 if you send a 200 header? That is, will your new header take precedence over the 404 the server was going to send? I assume that's the case with your 301 example above, right?
 
With all 40x error (and 50x) it's the server that sends the status code and then displays either the standard 40x page or the custom page specified in IIS properties, not the page sending a response code. My 301 example was for when you need to remove or rename pages because in this case the server sends a 200 and the script adds 301.
It may well be that sending a 301 will overwrite the 404 but it may not have the effect that way2many was after, because it will tell the SE crawler that the link it followed is a dead end and the URL specified in the location header is the one to index, and as it will never find any other links to that page it will eventually drop the dead link and may never put the redirected link in the index.

In any case most SEs do not have a problem with 1 or even 2 querystring parameters ( ) more than 2 and they may not index them, Session IDs and a parameter with ID as the name does prevent indexing.



Chris.

Indifference will be the downfall of mankind, but who cares?
 
Thank you Chris & Genimuse!

Now I'm totally conused.

I think that ~1 year ago I came accross a very long post (over 100 messages) on one of the SE Optimization forums about dynamic webpages and people were discussing successful err 404 methods with redirection.
Many were saying that with err 404 they managed to list thousands of product pages.
I know that recently Google and HotBot began spidering URLs with "?" but I'm not sure that "&" in the query string would still be a problem.
I think that I'll have both types of links and see what will work and what will not...
Anyway, I'd appreciate any links/info related to my problem.
I've looked at Tek-Tips's SEO forum but it looks dead...
 
Chris, here is one article:


<<Actually, the server just redirects the browser to the page, instead of calling the page and returning. This is important to understand, here are the steps in order:

1.User enters an address into the browser.
2.The browser makes a request to the server.
3.The server determines that page doesn't exist.
4.The server consults the custom error map and looks up the new URL.
5.Instead of returning a 404 status to the browser the server returns a 301, with a URL.
6.The browser determines the URL is a redirection and calls the URL that was returned from the server.
7.The URL returned from the server is displayed in the browser.>>
 
It's a good article and I have seen lots of conflicting discussion on various SE and Tech forums about the best approach. I shall have to do some testing to prove it to myself!

The biggest problem of course is the risk of creating a better "spider trap" than dynamic URLs can ever do alone.

The SEO forum has been a little quiet lately, but there are some very good SEO forums around that are worth 'lurking' at.


are quite possibly the best places on the net to gain knowledge and information from the top ethical SEOs around.



Chris.

Indifference will be the downfall of mankind, but who cares?
 
Chris, you wrote: "With all 40x error (and 50x) it's the server that sends the status code and then displays either the standard 40x page or the custom page specified in IIS properties, not the page sending a response code. My 301 example was for when you need to remove or rename pages because in this case the server sends a 200 and the script adds 301."

Can you not override the status code in ASP?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top