Forum Moderators: open

Message Too Old, No Replies

404 custom error in .asp

problem with server.transfer address

         

Aberdeen

6:37 am on Jun 16, 2004 (gmt 0)

10+ Year Member



I am using the following code for my custom error on my asp site:

<%
' Get the Page Name
strQ = Request.ServerVariables("QUERY_STRING")

' Find the Model Number
nIndex = InStrRev(strQ,"/")
If (nIndex>0) Then
strModelNumber = Right(strQ,Len(strQ)-nIndex)
strQ = Left(strQ,nIndex-1)
End If

' Trim Off .htm From Model Number
strModelNumber =Left(strModelNumber,Len(strModelNumber)-4)
strModelNumber =Right(strModelNumber,Len(strModelNumber)-4)

Session("username")=strModelNumber
Server.Transfer("/Desc_test.asp")
%>

It is an attempt to make dynamic pages appear static. It works, but the problem is the url that appears in the address bar comes out like this:

[****xx.com...]

I thought by using a server.transfer, the url was supposed to remain static. Can anyone help. I am a bit confused.

Cheers

Aberdeen

12:56 pm on Jun 16, 2004 (gmt 0)

10+ Year Member



I was really hoping someone could help me. I read somewhere that by setting the Application Extension Mapping to check the file exists, would solve my problem, but it does not.

Does anybody have any ideas?

macrost

10:52 pm on Jun 16, 2004 (gmt 0)

10+ Year Member



You really need to send a 200 ok from the server

Response.Status = "200 OK"

when your conditions for a match meet. Otherwise send a:

Response.Status = "404 Not Found"

How are your links formatted that hit the 404 page? Are they like: h*tp://www.example.com/asdf/qwerty/model/id?

Aberdeen

2:12 am on Jun 17, 2004 (gmt 0)

10+ Year Member



They are formatted like:

h**p://www.example.com/drive/fast/cars34.asp

I cut of the everything to leave me with the number, and that number is the product id.

Where do I add the Response.Status = "200 OK" in my code, before the server.transfer?

Thankyou very much for your help.

Cheers

Aberdeen

4:45 am on Jun 17, 2004 (gmt 0)

10+ Year Member



I am sorry to answer myself here, but by solving one problem I have created another.

I realised that if I used the url:
h..p://www.****.com/xx/xx/32/

and the response.status "200 ok"

it solved by problem with the 404;http:// in the address bar.

My new problem is that the when I use the server.transfer the page works fine, but it is looking for the images in a directory that does not exist (xx/xx/32/images/).

How do I solve this problem. They are virtual links, and I would like them to stay like that.

Any help please.

Cheers