Non-existent page is not throwing 404 error

J

Joel D. Kraft

I've been logging a lot of fatal errors on my site lately, and I
have not been able to figure out why.

First, my site has error handling pages defined globally as shown
below. They are not overridden at any point in the configuration.

<customErrors mode="RemoteOnly"
defaultRedirect="/site/error/default.aspx">
<error statusCode="404" redirect="/site/error/404.aspx" />
</customErrors>

Oddly enough, I am getting exceptions logged that SHOULD be sent to
the 404 page. In this instance, the page requested is
/site/news/rss_sharepoint.aspx. THIS PAGE DOES NOT AND SHOULD
NOT EXIST, which is obviously why it cannot find what it is looking
for. The question is WHY is it getting this far, instead of going
to my 404 handler?

Request: /site/news/rss_sharepoint.aspx
UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5)
Gecko/20041206 Thunderbird/1.0
Username: (none)
-----
System.IO.FileNotFoundException:
C:\InetSrv\wwwroot\site\news\rss_sharepoint.aspx
at System.Web.UI.TemplateParser.GetParserCacheItem()
at
System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.TemplateControlParser.GetCompiledInstance(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageParser.GetCompiledPageInstanceInternal(String
virtualPath, String inputFile, HttpContext context)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context,
String requestType, String url, String path)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
requestType, String path, String pathTranslated, Boolean useAppConfig)

To make things more confusing, I cannot reproduce it. If I
try to visit the page, I get the 404 page every time. But I'm getting
these errors logged a lot. Any insights?

Thanks!
Joel

--
 
A

arunprakashb

Hi Joel,
It might be because the Application_Error event fires before the
redirection to 404 handler happens.

Regards,
Arun Prakash. B
 
B

Brock Allen

Arun is right -- 404 is handled by ASP.NET throwing an exception, and your
Application_Error sounds like it's loggin everything that passes thru it.
If you only want the errors in your pages and not these ASP.NET exceptions,
you should check in Application_Error for HttpUnhandledException:

void Application_Error(...)
{
if (Context.Error is HttpUnhandledException)
{
// this is an error from one of my pages
}
}
 
J

Joel D. Kraft

Arun is right -- 404 is handled by ASP.NET throwing an exception, and
your Application_Error sounds like it's loggin everything that passes
thru it. > If you only want the errors in your pages and not these
ASP.NET exceptions, you should check in Application_Error for
HttpUnhandledException:

void Application_Error(...)
{
if (Context.Error is HttpUnhandledException)
{
}
}

DOH. This got me to finally dig up a comprehensive reference
on how the errors filter through the page, application and config.
I ended up rewriting my entire error handling mechanism. The
CustomErrors wasn't cutting it for me anyway.

Thanks guys!
Joel
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top