__Repro__
Setup a CORS enable web site and write a customized trace writer like this:
```
public class CustomTraceWriter : SystemDiagnosticsTraceWriter
{
public override void Trace(
HttpRequestMessage request,
string category,
TraceLevel level,
Action<TraceRecord> traceAction)
{
if (category == "System.Web.Http.Request")
{
base.Trace(request, category, level, traceAction);
}
}
}
```
Trigger a "complex" request with involving preflight OPTIONS request.
Observe the output window in Visual Studio, you will see log like: (noises are removed)
```
iisexpress.exe Information: 0 : Request, Method=GET, Url=http://localhost:27032/odata/Movies?$top=20, Message='http://localhost:27032/odata/Movies?$top=20'
iisexpress.exe Information: 0 : Response, Status=200 (OK), Method=GET, Url=http://localhost:27032/odata/Movies?$top=20, Message='Content-type='application/json; charset=utf-8', content-length=unknown'
```
The OPTIONS request is not logged.
__Root__
CorsMessageHandler is added at end of message handler pipeline but before RequestMessageHandlerTracer. It is because default HttpConfiguration initializer execute ITraceManager initialization after EnableCors.
__Customer Impact__
Some customers relies on the tracer writer to audit all request and response inbound and outbound. This issue preventing them from logging OPTIONS request/response in CORS scenario.
Setup a CORS enable web site and write a customized trace writer like this:
```
public class CustomTraceWriter : SystemDiagnosticsTraceWriter
{
public override void Trace(
HttpRequestMessage request,
string category,
TraceLevel level,
Action<TraceRecord> traceAction)
{
if (category == "System.Web.Http.Request")
{
base.Trace(request, category, level, traceAction);
}
}
}
```
Trigger a "complex" request with involving preflight OPTIONS request.
Observe the output window in Visual Studio, you will see log like: (noises are removed)
```
iisexpress.exe Information: 0 : Request, Method=GET, Url=http://localhost:27032/odata/Movies?$top=20, Message='http://localhost:27032/odata/Movies?$top=20'
iisexpress.exe Information: 0 : Response, Status=200 (OK), Method=GET, Url=http://localhost:27032/odata/Movies?$top=20, Message='Content-type='application/json; charset=utf-8', content-length=unknown'
```
The OPTIONS request is not logged.
__Root__
CorsMessageHandler is added at end of message handler pipeline but before RequestMessageHandlerTracer. It is because default HttpConfiguration initializer execute ITraceManager initialization after EnableCors.
__Customer Impact__
Some customers relies on the tracer writer to audit all request and response inbound and outbound. This issue preventing them from logging OPTIONS request/response in CORS scenario.