This project has moved. For the latest updates, please go here.

Multiple registrations of the same path

Jan 3, 2015 at 4:36 AM
1) What happens if the same path is registered more than once?
2) How can I retrieve a list of paths that have been registered before me?

For example, if two middleware components map the same path does the first one registered win, last one, or does Katana run all code blocks. It would appear in my test that only the first one is executing but this is a superficial observation.
app.Map("/dashboard", config =>
{
    config.Use((context, next) =>
    {
            context.Response.ContentType = "text/html";
            return context.Response.WriteAsync("<html><body>I'm first, I think</body></html>");
    });
});

app.Map("/dashboard", config =>
{
    config.Use((context, next) =>
    {
            context.Response.ContentType = "text/html";
            return context.Response.WriteAsync("<html><body>I'm second, I guess..</body></html>");
    });
});
Coordinator
Jan 3, 2015 at 5:03 AM
Yes, the first one wins. There is no master route table, middleware is all Russian doll modeled so you can't tell what happened in the pipeline before you, only that nobody else handled the request yet and it got passed down to you. See http://katanaproject.codeplex.com/SourceControl/latest#src/Microsoft.Owin/Mapping/MapMiddleware.cs