By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,276 Members | 1,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,276 IT Pros & Developers. It's quick & easy.

Using RewritePath - but I want to send the user to a 404

P: n/a
For a customer I have created a website, where we use dynamic url-rewrites
by using rewritepath in global.asa.

Ie the url /products/gizmo.aspx does not really exist, but I look gizmo up
in the db and find the relevant product, and then do a rewritepath to
productpresentation.aspx?id=whatever

But in some cases, I get a request for /products/someoddproduct.aspx which
does not exist. I then want to send the user a 404-error from code. How do I
do that?

Thanks in advance

- Klaus
Apr 25 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
By simply not rewriting the URL this should happen.

Which URL rewriting setup are you using?

Cheers,

Greg
"Klaus Jensen" <sp******@burninhell.com> wrote in message
news:Om**************@TK2MSFTNGP05.phx.gbl...
For a customer I have created a website, where we use dynamic url-rewrites
by using rewritepath in global.asa.

Ie the url /products/gizmo.aspx does not really exist, but I look gizmo up
in the db and find the relevant product, and then do a rewritepath to
productpresentation.aspx?id=whatever

But in some cases, I get a request for /products/someoddproduct.aspx which
does not exist. I then want to send the user a 404-error from code. How do
I do that?

Thanks in advance

- Klaus

Apr 26 '06 #2

P: n/a
"Greg Young [MVP]" <Dr*************@hotmail.com> wrote in message
news:uW**************@TK2MSFTNGP05.phx.gbl...
By simply not rewriting the URL this should happen.
I'm sitting here laughing at myself... I dont know why I did not think of
that. Thanks. :)
Which URL rewriting setup are you using?


In Application_BeginRequest I evaluate the URL. If it's
/Products/Gizmo.aspx, I look in the db for the product gizmo, retrieve the
pageId for it and rewrite the url to Productpresentation.aspx?id=xxx

And now if gizmo does not exist, I keep my dirty paws off the big red
"RewriteUrl"-button.:D
Apr 26 '06 #3

P: n/a
This did make me smirk a bit...........lol

Incidentally, the code you would have needed had you been catching this and
trying to provide a response would be something like this.

Response.StatusCode = 404;
Response.StatusDescription = "Not Found";
Response.Write("<h2>Page not found</h2>");
Response.End();
--
Regards

John Timney
Microsoft MVP

"Klaus Jensen" <sp******@burninhell.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Greg Young [MVP]" <Dr*************@hotmail.com> wrote in message
news:uW**************@TK2MSFTNGP05.phx.gbl...
By simply not rewriting the URL this should happen.


I'm sitting here laughing at myself... I dont know why I did not think of
that. Thanks. :)
Which URL rewriting setup are you using?


In Application_BeginRequest I evaluate the URL. If it's
/Products/Gizmo.aspx, I look in the db for the product gizmo, retrieve the
pageId for it and rewrite the url to Productpresentation.aspx?id=xxx

And now if gizmo does not exist, I keep my dirty paws off the big red
"RewriteUrl"-button.:D

Apr 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.