aspx to return a 404 with a friendly page inc/Session?

D

Dunc

Has anyone got a way to get asp.net to return a result code of 404
with a friendly page of any substance?

I have been trying to do a Server.Transfer from the global.asax.cs
Application_Error function, but because there's no access to the
session at this point (Application_OnAuthenticateRequest hasn't fired)
and my master page checks session values based on the transferred
context (that has no session when transferred from the error handler),
I get an error.

If I use Response.Redirect or the <customerrors> tag, I get a response
code of 302.

I've set up IIS to point to the aspx file, but that only works if the
user hits a non-existant page without an aspx extension; any aspx file
gets handled by .net and we end up with either a response code of 302
or an error.

This is REALLY annoying, as every time a page name changes, I end up
with legacy search engine traffic I don't want. I've been trying to
do this for a long time now; there must be some solution out there?

Thanks in advance,

Duncan
 
M

Michael Nemtsev [MVP]

Hello Dunc,

Have u tried to implement the httphandler for this, where your session will
be available via IReadOnlySessionState|IRequiresSessionState.

see discussion there http://forums.asp.net/p/1273530/2414745.aspx

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


D> Has anyone got a way to get asp.net to return a result code of 404
D> with a friendly page of any substance?
D>
D> I have been trying to do a Server.Transfer from the global.asax.cs
D> Application_Error function, but because there's no access to the
D> session at this point (Application_OnAuthenticateRequest hasn't
D> fired) and my master page checks session values based on the
D> transferred context (that has no session when transferred from the
D> error handler), I get an error.
D>
D> If I use Response.Redirect or the <customerrors> tag, I get a
D> response code of 302.
D>
D> I've set up IIS to point to the aspx file, but that only works if the
D> user hits a non-existant page without an aspx extension; any aspx
D> file gets handled by .net and we end up with either a response code
D> of 302 or an error.
D>
D> This is REALLY annoying, as every time a page name changes, I end up
D> with legacy search engine traffic I don't want. I've been trying to
D> do this for a long time now; there must be some solution out there?
D>
D> Thanks in advance,
D>
D> Duncan
D>
 
D

Dunc

Thanks for the response; unfortunately the method they're chasing is
has almost identical problems to the one I've found. Because you're
adding a handler for context.Error, there's no
Application_OnAuthenticateRequest, which means no session, which means
it bombs when it does a Server.Transfer to a page that has a master
page with some very basic functionality.

Any other ideas?
 

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

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,244
Members
46,839
Latest member
MartinaBur

Latest Threads

Top