私はASP.NET Coreパイプラインの仕組みを理解しようとしています。 StaticFileMiddleware
を使用して、いくつかのオプションを渡したいと思います。ミドルウェア<Type>(...)を使用してオプションを渡すにはどうすればよいですか?
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
var staticFileOptions = new StaticFileOptions();
app.UseMiddleware<Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware>(staticFileOptions);
}
私は、私は次のエラー
System.InvalidOperationException: A suitable constructor for type 'Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.
at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass3_0.<UseMiddleware>b__0(RequestDelegate next)
at Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
を取得し、私のアプリケーションを実行すると、私は、これは学習運動です、私がしたいと私はちょうど、
app.UseStaticFiles(staticFileOptions);
を使用しますが、できることを理解してそれを他の方法で呼んでください。