【问题标题】:Unable to find Use.RunTimePageInfo() method in startup.cs file in asp.net core在 asp.net 核心的 startup.cs 文件中找不到 Use.RunTimePageInfo() 方法
【发布时间】:2016-11-05 06:25:14
【问题描述】:

我正在关注 Scott Allen 在 Ubuntu 16.04 .Net Core 1.0.0 框架中的 Asp.Net core Pluralsight 课程。我无法在 StartUp.cs 文件的 Configure 方法中找到 app.UseRuntimeInfoPage 方法,即使我已包含 Microsoft.AspNetCore.Diagnostics。该框架在提供的功能方面对非 Windows 操作系统有限制吗?

Scott Allen 课程中的 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);
    }
}

【问题讨论】:

    标签: c# asp.net .net


    【解决方案1】:

    此功能已在不久前删除。 https://github.com/aspnet/Home/issues/1632

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

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

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

    更新:

    似乎 issue #280 已更新,表明该功能将不会被恢复。

    【讨论】:

    • #280 已更新,表示他们不打算恢复该功能。
    猜你喜欢
    • 2017-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-25
    • 2021-10-01
    • 1970-01-01
    • 2018-10-31
    • 2019-08-07
    相关资源
    最近更新 更多