Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Allow Null params to middleware constructor? #331

@kspearrin

Description

@kspearrin

I want to do this from Startup.cs:

app.UseMiddleware<MyMiddleware>( foo );

MyMiddleware looks like this:

public class MyMiddleware
{
    private readonly RequestDelegate m_next;

    public MyMiddleware( RequestDelegate next, Foo foo )
    {
        m_next = next;
        // use foo
    }

    public async Task Invoke( HttpContext httpContext )
    {
        await m_next( httpContext );
    }
}

Yet I keep getting:

System.InvalidOperationException
Unable to locate suitable constructor for type 'MyMiddleware'. Ensure the type is concrete and all parameters are accepted by a constructor.

How do I pass additional parameters in my middleware constructor?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions