If I call the middleware directly in my startup.cs
, e.g.:
public void Configure(IApplicationBuilder app)
{
app.UseMiddleware<StaticFileMiddleware>();
app.UseMiddleware<DefaultFilesMiddleware>();
}
Looking at the source on GitHub, this is exactly the code that the extension methods are calling. However, I'm getting a 500 error and a stack trace:
:(
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()
This might be related to my No Static Files Extensions are referable question.
Either way, I currently can't get a simple index.html
page to load successfully.
Any help?
Thanks
You can also just call:
instead of the UseMiddleware methods.
You're probably using the RC1 version of the StaticFiles library inside of your project, instead of RC2.
In
project.json
, change this:To this:
The namespace also changed, but once that's corrected you should be good to go.
Since now the asp.net core 1.0 has been released. The correct NuGet package is: (notice: .AspNetCore.)
and you can use (again)