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

标签 c# asp.net .net

我正在学习 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/

相关文章:

c# - 什么是静态索引器?

c# - Datagridview 未显示在网页中

c# - 使用 LINQ 按多个属性分组并求和

sql - 在表连接中使用 COUNT 函数

asp.net - 使用 'System.Web.Optimization' 压缩由 asp.net 捆绑创建的 bundle ?

.net - DNU 从 MSBuild 发布 --no-source

javascript - getContext(2d) & drawImage > toDataURL > undefiend 问题

c# - Entity Framework - 加载子集合,按子属性排序

c# - 如何在c#中制作带圆角的文本框?

.net - 无法让我的正则表达式匹配