我的Microsoft.AspNet.StaticFiles
中引用了project.json
,但仍未识别UseDefaultFiles()
和UseStaticFiles()
个扩展程序。
project.json
的依赖关系部分是:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final"
}
我可以在解决方案资源管理器的参考部分看到该引用。我可以在Git repo中看到它存在于Microsoft.AspNetCore.Builder
命名空间中,UseDefaultFiles()
也是如此,但我只是遇到编译错误:
IApplicationBuilder' does not contain a definition for 'UseDefaultFiles' and no extension method 'UseDefaultFiles' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?)
但是,我可以在没有扩展方法的情况下直接访问中间件:
app.UseMiddleware<StaticFileMiddleware>();
app.UseMiddleware<DefaultFilesMiddleware>();
很好。
发生了什么事?
答案 0 :(得分:2)
像Daniel Grim所说:
将依赖项更改为:
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final"
套餐:https://www.nuget.org/packages/Microsoft.AspNetCore.StaticFiles/1.0.0-rc2-final