WCF, WebAPI and OWIN IIS integrated pipeline. Skip OWIN based on route

我是研究僧i 提交于 2019-12-04 07:35:06
Simon Fox

I've managed to get this to work via a Branched Pipeline.

app.MapWhen(c => c.Request.Path.Value.Contains("/api"),
                    subApp =>
                    {
                        subApp.UseJsonWebToken(
                            issuer: clientDetails.Issuer,
                            audience: clientDetails.Audience,
                            signingKey: clientDetails.SigningKey);

                        subApp.UseClaimsTransformation(transformer.Transform);

                        var webApiConfig = WebApiConfig.Configure();
                        webApiConfig.DependencyResolver = StructureMapConfig.HttpDependencyResolver();
                        subApp.UseWebApi(webApiConfig);
                    });

Only thing I'm wondering is why IAppBuilder.MapWhen as above works, but when I use IAppBuilder.Map it doesn't seem to work...

app.Map("/api",
        subApp => ...

Big thanks to the answer above. With this piece of code, I was able to figure out how to conditionally route calls so that WCF calls are not grabbed by static content middleware.

    //app.UseMiddleware<ServeStaticFilesMiddleware>();

    app.MapWhen(c => !c.Request.Path.Value.Contains(".svc"),
            subApp =>
            {
                subApp.UseMiddleware<ServeStaticFilesMiddleware>();
            });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!