404 errors and Server.Transfer

S

Shaun Wilde

I am trying to handle a 404 errors and redirect them to the correct page
based on criteria

I was hoping to catch the error in the global error handler and forward via
Server.Transfer to the correct page such that it would appear to be the page
requested. ow this does work to a fashion but it seems that I don't have
access to the session state when I undergo a Server.Transfer from the
Application_Error.

Can anyone suggest another way of achieving my goal i.e. if a request is
made to a page that does not exists I can use the name of the requested page
and redirect it to the correct page within my site but do it such that the
browser does not change its URL in the address.

I want to avoid Response.Redirect due to problems I have with google and it
just abandoning the search of the site when these requests happen to it.

Thanks

Shaun
 
M

[MSFT]

Hi Shaun,

I think the <Customerrors> element in web.config is a proper solution for
the issue:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
ml/gngrfCustomerrorsSection.asp

For example you can set like:

<customErrors defaultRedirect="DefaultErr.aspx"
mode="On">
<error statusCode="404"
redirect="My404Err.aspx"/>
</customErrors>

In My404Err.aspx, you can get the original request page url by:

Request.QueryString["aspxerrorpath"]

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Shaun Wilde

Yes I am aware of this route - however as I said before I wish to hide the
redirection if I can as I know this upsets search engines like google if it
happens too often on a site as it thinks its being conned (ie content is
being generated just for the benefit of the google engine in order to
increase site ranking)

Also the use in many portal products of querystrings also upsets google as
it does not navigate these sites properly or has stopped doing so according
to logs I have been given - so virtual pages would be an ideal solution to
this problem.

Shaun
 
S

Shaun Wilde

A page that looks like it is there but doesn't exist in any real sense and
could be either created on the fly, or uses another page to masquarde as it.

In my case I would lke a request for xxx.aspx to be generated by a transfer
to Virtual.aspx (which has already been preset with some values to generate
the content)
 
S

Shaun Wilde

thanks - that may be the answer - lets hope my ISP has no policy that would
prevent me from employing this solution
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top