启动类包含
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设置为“开发”
在本规范中
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)