Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: [Cors] RequestMessageHandlerTracer is not executed for OPTIONS preflight request. [962]

$
0
0
__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.
Comments: It also hides the category "System.Web.Http.MessageHandlers" traces. Because the TraceManager add one addition trace message handler __after__ each message handler. CORS message handler short cut the pipeline by replying preflight request directly. Therefore the MessageHandlerTracer is not executed either.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>