默认vNext Web项目包含这样的行 Startup.cs :
如果(string.Equals(env.EnvironmentName,发展,StringComparison.OrdinalIgnoreCase)){ app.UseBrowserLink(); app.UseErrorPage(ErrorPageOptions.ShowAll);}其他{ app.UseErrorHandler(/首页/错误);}据我了解,在EnvironmentName是处理开发/生产环境的新途径。但它确实在发布版本的配置不能更改。那么,什么是设置方式不同 EnvironmentName ?
我可以想像,它应该在命令被设置为服务器的参数。
解决方案我可以想像,它应该在命令被设置为服务器的参数。
这才是真正的。在你project.json,添加 - ASPNET_ENV生产为服务器的参数
project.json 命令:{ 网络:Microsoft.AspNet.Hosting --ASPNET_ENV生产--server Microsoft.AspNet.Server.WebListener --server.urls的http://本地主机:5001}现在,当您运行 DNX。网络在命令行中, ASPNET_ENV 将制作。
天青我们也不能在Azure的WEB设置APP>配置>应用程序设置区域。
Default vNext web project contain such lines in Startup.cs:
if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase)) { app.UseBrowserLink(); app.UseErrorPage(ErrorPageOptions.ShowAll); } else { app.UseErrorHandler("/Home/Error"); }As I understand, the EnvironmentName is a new way to handle Dev/Production environment. But it doesn't changes on Release build configuration. So what is the way to set a different EnvironmentName?
I can imagine that it should be set in "Commands" as a parameter for server.
解决方案I can imagine that it should be set in "Commands" as a parameter for server.
That is true. In your project.json, add --ASPNET_ENV production as a parameter for the server.
project.json "commands": { "web": "Microsoft.AspNet.Hosting --ASPNET_ENV production --server Microsoft.AspNet.Server.WebListener --server.urls localhost:5001" }Now when you run dnx . web from the command line, ASPNET_ENV will be production.
AzureWe cannot also set in from the Azure WEB APP > CONFIGURE > app settings area.
更多推荐
如何设置IHostingEnvironment.EnvironmentName在vNext应用程序?
发布评论