如果我直接在 my 中调用中间件startup.cs
,例如:
public void Configure(IApplicationBuilder app)
{
app.UseMiddleware<StaticFileMiddleware>();
app.UseMiddleware<DefaultFilesMiddleware>();
}
查看GitHub 上的源代码,这正是扩展方法正在调用的代码。但是,我收到 500 错误和堆栈跟踪:
:(
Oops.
500 Internal Server Error
System.InvalidOperationException
The 'Invoke' method's first argument must be of type 'HttpContext'.
at Microsoft.AspNetCore.Builder.<>c__DisplayClass3_0.<UseMiddleware>b__0(RequestDelegate next)
at Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
Show raw exception details
System.InvalidOperationException: The 'Invoke' method's first argument must be of type 'HttpContext'.
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass3_0.b__0(RequestDelegate next)
at Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
这可能与我的No Static Files Extensions are referable问题有关。
无论哪种方式,我目前都无法index.html
成功加载一个简单的页面。
有什么帮助吗?
谢谢