I am currently working on a .net c# web application. I have removed several .aspx from the site (deleted them) eg page1.aspx, page2.aspx etc.
What I want to do now is create a http module that when the page1.aspx or page2.aspx is called by a users browser, instead of returning a 404 status code, return the appropriate status code for a deleted page and redirect the user to the home page, rather than an error page.
What is the best way of achieving this, is it via a http module and if so, I would I set such up?
If there are only a few pages you could just leave them there with Response.StatusCode = 410
and a simple window.location = basepage
.
If it is a dynamic list that can grow large i would put it in your application error handler:
protected void Application_Error(Object sender, EventArgs e)
{
if (/*requesting a deleted resource*/)
{
//return status 410 and a javascript redirect
}
}