无法在aspnet核心的startup.cs文件中找到Use.RunTimePageInfo()方法

时间:2016-07-03 10:46:25

标签: c# asp.net .net

我在Ubuntu 16.04 .Net Core 1.0.0框架中遵循Scott Allen的Asp.Net核心复数课程。我无法在StartUp.cs文件中的Configure方法中找到app.UseRuntimeInfoPage方法,即使我已包含Microsoft.AspNetCore.Diagnostics。在提供的功能方面,框架是否对非Windows操作系统有限制?

Scott Allens课程的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();
            }

            // 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(args);
        }
    }


2 个答案:

答案 0 :(得分:7)

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

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

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

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

答案 1 :(得分:0)

Use.RunTimePageInfo() 没有这样的方法......

请显示启动代码