Skip to content

Commit afe6551

Browse files
Fix issue - #73
1 parent 3818245 commit afe6551

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/Microsoft.AspNet.TelemetryCorrelation/TelemetryCorrelationHttpModule.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,21 @@ private void Application_EndRequest(object sender, EventArgs e)
105105
// BeginRequest has never been called
106106
if (!context.Items.Contains(BeginCalledFlag))
107107
{
108-
// Activity has never been started
109-
ActivityHelper.CreateRootActivity(context, ParseHeaders);
108+
// Exception happened before BeginRequest
109+
if (context.Error != null)
110+
{
111+
// Activity has never been started
112+
ActivityHelper.CreateRootActivity(context, ParseHeaders);
113+
}
114+
else
115+
{
116+
// Rewrite: In case of rewrite, a new request context is created, called the child request, and it goes through the entire IIS/ASP.NET integrated pipeline.
117+
// The child request can be mapped to any of the handlers configured in IIS, and it's execution is no different than it would be if it was received via the HTTP stack.
118+
// The parent request jumps ahead in the pipeline to the end request notification, and waits for the child request to complete.
119+
// When the child request completes, the parent request executes the end request notifications and completes itself.
120+
// Ignore creating root activity for parent request as control got transferred from rewrite module to EndRequest with no request flow.
121+
return;
122+
}
110123
}
111124

112125
ActivityHelper.StopAspNetActivity(context.Items);

0 commit comments

Comments
 (0)