问题描述
我在 project.json
中引用了 Microsoft.AspNet.StaticFiles
,但 UseDefaultFiles()和 UseStaticFiles()
扩展名。
I have Microsoft.AspNet.StaticFiles
referenced in my project.json
, but the UseDefaultFiles()
and UseStaticFiles()
extensions are still not recognised.
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"
}
我可以在解决方案资源管理器的参考部分中看到参考。我可以在中看到它位于 Microsoft.AspNetCore.Builder
命名空间中,与 UseDefaultFiles()
一样,但我只是遇到编译错误:
I can see the reference in the references section of the solution explorer. I can see in the Git repo that it lives in the Microsoft.AspNetCore.Builder
namespace, as does UseDefaultFiles()
but I just get a compile error:
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?)
我可以,但是,不使用扩展方法即可直接访问中间件:
I can, however, access the middleware directly without the extension methods:
app.UseMiddleware<StaticFileMiddleware>();
app.UseMiddleware<DefaultFilesMiddleware>();
很好。
发生了什么?
推荐答案
像Daniel Grim所说:
Like Daniel Grim says:
将依赖项更改为:
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final"
软件包:
这篇关于没有静态文件扩展名可参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!