![](/img/trans.png)
[英]how to change property value of scoped service at configure method of startup.cs file in asp.net core
[英]Unable to find Use.RunTimePageInfo() method in startup.cs file in asp.net core
我正在 Ubuntu 16.04 .Net Core 1.0.0 框架中學習 Scott Allen 的 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);
}
}
此功能前段時間已被刪除。 https://github.com/aspnet/Home/issues/1632
此外,它似乎計划在不確定的時間回來。 https://github.com/aspnet/Diagnostics/issues/280
所以現在你可以從你的 startup.cs 中刪除它; 或添加代碼並從此提交創建您自己的版本: https : //github.com/aspnet/Diagnostics/commit/af19899927516718bdc05507612dcc17901fb937
我不提供代碼示例,因為代碼在上面提到的提交中。
更新:
似乎問題 #280 已更新以聲明該功能根本不會恢復。
Use.RunTimePageInfo()沒有這樣的方法......
請顯示啟動代碼
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.