没有静态文件扩展名可参考 [英] No Static Files Extensions are referable

查看:130
本文介绍了没有静态文件扩展名可参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 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"
}

我可以在解决方案资源管理器的参考部分中看到参考。我可以在 Git存储库中看到它位于 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"

软件包: https://www.nuget.org/packages/Microsoft.AspNetCore.StaticFiles/1.0.0-rc2-final

这篇关于没有静态文件扩展名可参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆