gpt4 book ai didi

c# - 无法在 asp.net core 的 startup.cs 文件中找到 Use.RunTimePageInfo() 方法

转载 作者:太空狗 更新时间:2023-10-29 18:34:44 27 4
gpt4 key购买 nike

我正在学习 Scott Allen 在 Ubuntu 16.04 .Net Core 1.0.0 框架中的 Asp.Net core Pluralsight 类(class)。我无法在 StartUp.cs 文件的 Configure 方法中找到 app.UseRuntimeInfoPage 方法,即使我已经包含了 Microsoft.AspNetCore.Diagnostics。该框架在提供的功能方面是否对非 Windows 操作系统有限制?

Scott Allen 类(class)中的 StartUp.cs 代码

using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using OdeToFood.Services;

namespace OdeToFood
{
public class Startup
{
public Startup()
{
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json");
Configuration = builder.Build();
}

public IConfiguration Configuration { get; set; }

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSingleton(provider => Configuration);
services.AddSingleton<IGreeter, Greeter>();
}

// This method gets called by the runtime.
// Use this method to configure the HTTP request pipeline.
public void Configure(
IApplicationBuilder app,
IHostingEnvironment environment,
IGreeter greeter)
{
app.UseIISPlatformHandler();

if (environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseRuntimeInfoPage("/info");

app.UseFileServer();

app.UseMvcWithDefaultRoute();

app.Run(async (context) =>
{
var greeting = greeter.GetGreeting();
await context.Response.WriteAsync(greeting);
});

}

// Entry point for the application.
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}
}

最佳答案

此功能已在一段时间前删除。 https://github.com/aspnet/Home/issues/1632

此外,它似乎计划在不确定的时间返回。 https://github.com/aspnet/Diagnostics/issues/280

所以现在您可以将它从您的 startup.cs 中删除;或添加代码并从此提交创建您自己的版本: https://github.com/aspnet/Diagnostics/commit/af19899927516718bdc05507612dcc17901fb937

我没有提供代码示例,因为代码在上面提到的提交中。

更新:

问题 #280 似乎已更新为声明该功能根本不会恢复。

关于c# - 无法在 asp.net core 的 startup.cs 文件中找到 Use.RunTimePageInfo() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38169158/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com