Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOS throws ArgumentException when using WebApi middleware #8

Open
mikdav opened this issue May 16, 2018 · 0 comments
Open

FOS throws ArgumentException when using WebApi middleware #8

mikdav opened this issue May 16, 2018 · 0 comments

Comments

@mikdav
Copy link

mikdav commented May 16, 2018

I got FOS from nuget and tried to use it with Microsoft.AspNet.WebApi.Owin, and got the following exception when making a request:

System.ArgumentException: Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.
at System.Delegate.CreateDelegate(Type type, Object target, String method, Boolean ignoreCase, Boolean throwOnBindFailure)
at Fos.Owin.OwinMiddleware.BuildHandler()
at Fos.Owin.OwinMiddleware.get_Handler()
at Fos.Owin.OwinMiddleware.Invoke(IDictionary`2 owinParameters)
at Fos.Listener.FosRequest.ProcessRequest()

I cloned the repository and debugged through it. The problem appears to be that FosAppBuilder expects all middleware to have an Invoke method can be created as a delegate of type Func<IDictionary<string, object>, Task>. Several of the newer middlewares have an invoke method signature of Func<Microsoft.Owin.IOwinContext, Task>. The System.Web.Http.Owin,HttpMessageHandlerAdapter middleware registered by UseWebApi() is one of these middlewares.

Microsoft.Owin.Builder.AppBuilder already handles conversion between these two signatures and by having FosAppBuilder inherit from Microsoft.Owin.Builder.AppBuilder, I was able to successfully use the WebApi middleware over fastcgi for my application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant