In our Global.asax
file we have:
<code>protected void Application_Error()
Errors.Functions.HandleException(HttpContext.Current);
<code>protected void Application_Error()
{
Errors.Functions.HandleException(HttpContext.Current);
}
</code>
protected void Application_Error()
{
Errors.Functions.HandleException(HttpContext.Current);
}
On a 404
error, the following code is executed:
<code>context.Server.Transfer("~/pages/errors/404.aspx");
context.ApplicationInstance.CompleteRequest();
<code>context.Server.Transfer("~/pages/errors/404.aspx");
context.ClearError();
context.ApplicationInstance.CompleteRequest();
</code>
context.Server.Transfer("~/pages/errors/404.aspx");
context.ClearError();
context.ApplicationInstance.CompleteRequest();
This works absolutely fine for every 404 exception. However, we’re seeing odd requests in our logs to paths that don’t exist such as:
<code>https://www.example.com/en/meta.json
<code>https://www.example.com/en/meta.json
</code>
https://www.example.com/en/meta.json
Visiting this page serves a normal 404
response page as above, and doesn’t throw any exceptions.
However, these requests (I’m guessing from some vulnerability scanner or crawler) throw this exception on a daily basis:
<code>TYPE: HttpException
BASE TYPE: ExternalException
MESSAGE: Error executing child request for /pages/errors/404.aspx.
at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
at System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path)
at C3.Code.Controls.Application.Errors.Functions.HandleException(HttpContext context) in ...HandleHTTPException.cs:line 81
<code>TYPE: HttpException
BASE TYPE: ExternalException
MESSAGE: Error executing child request for /pages/errors/404.aspx.
SOURCE:
System.Web
STACK TRACE:
at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
at System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path)
at C3.Code.Controls.Application.Errors.Functions.HandleException(HttpContext context) in ...HandleHTTPException.cs:line 81
</code>
TYPE: HttpException
BASE TYPE: ExternalException
MESSAGE: Error executing child request for /pages/errors/404.aspx.
SOURCE:
System.Web
STACK TRACE:
at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
at System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
at System.Web.HttpServerUtility.Transfer(String path)
at C3.Code.Controls.Application.Errors.Functions.HandleException(HttpContext context) in ...HandleHTTPException.cs:line 81
Line 81 is the context.Server.Transfer(..
line.
The inner exception is:
<code>TYPE: NullReferenceException
BASE TYPE: SystemException
Object reference not set to an instance of an object.
at C3.Pages.Errors._404.Page_Load(Object sender, EventArgs e) in ...PagesErrors404.aspx.cs:line 12
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
<code>TYPE: NullReferenceException
BASE TYPE: SystemException
MESSAGE:
Object reference not set to an instance of an object.
SOURCE:
C3Alpha2
STACK TRACE:
at C3.Pages.Errors._404.Page_Load(Object sender, EventArgs e) in ...PagesErrors404.aspx.cs:line 12
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
</code>
TYPE: NullReferenceException
BASE TYPE: SystemException
MESSAGE:
Object reference not set to an instance of an object.
SOURCE:
C3Alpha2
STACK TRACE:
at C3.Pages.Errors._404.Page_Load(Object sender, EventArgs e) in ...PagesErrors404.aspx.cs:line 12
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Where line 12 is on of the Page_Load
lines:
<code>public partial class _404 : System.Web.UI.Page
public Master_Pages.Main MP => (Master_Pages.Main) Master;
protected void Page_Load(object sender, EventArgs e)
MP.SEOPageHeader.Title = "File not found";
<code>public partial class _404 : System.Web.UI.Page
{
public Master_Pages.Main MP => (Master_Pages.Main) Master;
protected void Page_Load(object sender, EventArgs e)
{
MP.IsErrorPage = true;
MP.SEOPageHeader.Title = "File not found";
}
}
</code>
public partial class _404 : System.Web.UI.Page
{
public Master_Pages.Main MP => (Master_Pages.Main) Master;
protected void Page_Load(object sender, EventArgs e)
{
MP.IsErrorPage = true;
MP.SEOPageHeader.Title = "File not found";
}
}
The requests throwing the error are normal HTTP GET
requests, and logging details about the headers etc doesn’t show anything that looks too unusual.
Does anyone know what could be causing this to throw these exceptions?