我正在按照Scott Allen的Pluralsight课程尝试组装一个ASP.NET Core应用程序。我在macOS上。
我的project.json
依赖关系如下所示:
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final"
我还原了所有必要的软件包。
我的Startup.cs
样子是这样的:
...
public void Configure(IApplicationBuilder app)
{
app.UseFileServer(); // 'IApplicationBuilder' does not contain a definition for 'UseFileServer' and no extension method 'UseFileServer' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?) [netcoreapp1.0]
app.Run(context =>
{
return context.Response.WriteAsync("Hello from ASP.NET Core!");
});
}
...
我似乎已经具备所有依赖关系,但是编译器抱怨没有看到任何中间件的扩展方法(UseFileServer
例如)
有任何想法吗?
您需要将"Microsoft.AspNetCore.StaticFiles" : "1.0.0"
依赖项添加到project.json文件中,或者在单击Ctrl+.
错误时遵循IDE的建议(但是,如果该错误在Visual Studio Code中有效,则为dunno)。
另外,您可能必须包含Microsoft.AspNetCore.Builder
名称空间,因为该名称空间UseFileServer
位于静态文件库中
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句