小编dat*_*kom的帖子

Startup.cs返回错误的环境

启动类包含

public Startup(IHostingEnvironment env)
{
    var builder = new ConfigurationBuilder()
        .SetBasePath(env.ContentRootPath)
        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

    Console.WriteLine($"{env.EnvironmentName.ToString()}");

    if (env.IsDevelopment())
    {
        // For more details on using the user secret store see 
        // https://go.microsoft.com/fwlink/?LinkID=532709
        builder.AddUserSecrets();
    }

    builder.AddEnvironmentVariables();
    Configuration = builder.Build();
}
Run Code Online (Sandbox Code Playgroud)

但是env.EnvironmentName.ToString()返回“生产”。

我已经在launchSettings.json中将ASPNETCORE_ENVIRONMENT设置为“开发”

c# asp.net-core-mvc .net-core asp.net-core asp.net-core-1.0

5
推荐指数
2
解决办法
1415
查看次数

Nullable int作为动作参数

在本规范中

public ActionResult Index(int? id)
{
  return View();
}
Run Code Online (Sandbox Code Playgroud)

怎么int? id办?

我们也能用这种格式写吗?

public ActionResult Index()
{
  int id;
  return View();
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc

1
推荐指数
1
解决办法
2531
查看次数