Recently I tried to create a simple Owin middleware with params parameters.
My first version looked like this:
You can compile the code, because there is no syntax error. But eventually you will get runtime error similar to this:
A suitable constructor for type ‘test.TestMiddleware’ could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.
To fix this issue, you can introduce an OwinMiddlewareOptions parameter:
UseMiddleware method is not smart enough to create an instance of Owin middleware with params parameters. Use method in .NET Framework has similar issue.