发布到 IIS,设置环境变量 [英] Publish to IIS, setting Environment Variable

查看:58
本文介绍了发布到 IIS,设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读这两个问题/答案后,我能够在 IIS 8.5 服务器上运行 Asp.net 5 应用程序.

  • 设置环境变量.
  • 关闭窗口并点击应用.
  • 完成
  • 这样您就不必为您的池创建特殊用户或在 project.json 中创建额外的命令条目.此外,为每个环境添加特殊命令会破坏一次构建,多次部署",因为您必须为每个环境分别调用 dnu publish,而不是发布一次并多次部署生成的工件.>

    感谢 Mark G 和 tredder,针对 RC2 和 RTM 进行了更新.

    Reading these two questions/answers I was able to run an Asp.net 5 app on IIS 8.5 server.

    Asp.net vNext early beta publish to IIS in windows server

    How to configure an MVC6 app to work on IIS?

    The problem is that the web app is still using env.EnvironmentName with value Development even when run on IIS.

    Also, I want to run two versions of the same Web (Staging, Production) on the same server, so I need a method to set the variable for each Web separately.

    How to do this?

    解决方案

    This answer was originally written for ASP.NET Core RC1. In RC2 ASP.NET Core moved from generic httpPlafrom handler to aspnetCore specific one. Note that step 3 depends on what version of ASP.NET Core you are using.

    Turns out environment variables for ASP.NET Core projects can be set without having to set environment variables for user or having to create multiple commands entries.

    1. Go to your application in IIS and choose Configuration Editor.
    2. Select Configuration Editor
    3. Choose system.webServer/aspNetCore (RC2 and RTM) or system.webServer/httpPlatform (RC1) in Section combobox
    4. Choose Applicationhost.config ... in From combobox.
    5. Right click on enviromentVariables element, select 'environmentVariables' element, then Edit Items.
    6. Set your environment variables.
    7. Close the window and click Apply.
    8. Done

    This way you do not have to create special users for your pool or create extra commands entries in project.json. Also, adding special commands for each environment breaks "build once, deploy many times" as you will have to call dnu publish separately for each environment, instead of publish once and deploying resulting artifact many times.

    Updated for RC2 and RTM, thanks to Mark G and tredder.

    这篇关于发布到 IIS,设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆