I've followed advice on how to setup 404s by:
http://www.andornot.com/about/developerblog/archive/2009%5F10%5F01%5Farchive.aspx
and related:
http://stackoverflow.com/questions/667053/best-way-to-implement-a-404-in-asp-net
From Global.asax:
protected void Application_Error(Object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
if (exception is HttpUnhandledException)
{
if (exception.InnerException == null)
{
Server.Transfer(string.Format("~/Error.aspx", false));
return;
}
exception = exception.InnerException;
}
if (exception is HttpException)
{
if (((HttpException)exception).GetHttpCode() == 404)
{
Server.ClearError();
Server.Transfer("~/404.aspx", false);
return;
}
}
if (Context != null && Context.IsCustomErrorEnabled)
{
Server.Transfer(string.Format("~/Error.aspx"), false);
}
}
And from Web.config:
<customErrors mode="On"/>
It all works beautifully locally while testing (VS2010) but in production (ISS6) it only works for aspx pages. http://mysite.se/foo.js get me the ISS 404 page. ("The page cannot be found")
What am I missing?