I\'m writing my own OWIN middleware for OpenID Connect authorization code flow, based on other examples in the Katana Project.
As part of this I have to construct a coup
When using the construct
app.Map("/login", map => [...]
This uses
Owin.MapExtensions.Map
which constructs an instance of
Microsoft.Owin.Mapping.MapMiddleware
for the code which needs running.
The behaviour I have seen is explained in the Invoke method of this middleware:
public async Task Invoke(IDictionary environment)
{
IOwinContext context = new OwinContext(environment);
PathString path = context.Request.Path;
PathString remainingPath;
if (path.StartsWithSegments(_options.PathMatch, out remainingPath))
{
// Update the path
PathString pathBase = context.Request.PathBase;
context.Request.PathBase = pathBase + _options.PathMatch;
context.Request.Path = remainingPath;
await _options.Branch(environment);
context.Request.PathBase = pathBase;
context.Request.Path = path;
}
else
{
await _next(environment);
}
}
Basically the code changes the Path and PathBase before it runs the delegate (await _options.Branch(environment) ), then sets these back to the original values after execution is complete.
Hence the behaviour I had seen is explained.