简体   繁体   English

通过托管环境进行自我托管

[英]Pass hosting environment for self-hosting

I'm trying to run ASP.NET Core (.NET 4.6.1) application as self hosting by means of weblistener 我正在尝试通过weblistener将ASP.NET Core(.NET 4.6.1)应用程序作为自托管运行

I've add a command: 我添加了一个命令:

"commands": {
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000"
},

and necessary dependencies in project.json project.json必要依赖项

When I start my application via Visual Studio it's works fine 当我通过Visual Studio启动应用程序时,一切正常

src\ProjectName\bin\Release\net461\win7-x64\ProjectName.exe

ProjectName.exe starts as web server with Hosting environment: Development ProjectName.exe作为具有Hosting environment: Development Web服务器启动Hosting environment: Development

But when I run it by hand ProjectName.exe runs with Hosting environment: Production and it's not working properly. 但是,当我手动运行ProjectName.exe时,它可以在Hosting environment: Production运行Hosting environment: Production并且无法正常工作。 First of all I want find way to run application by hand with Development environment 首先,我想找到在Development environment手动运行应用程序的Development environment

In VS I have this option: 在VS我有这个选择:

在此处输入图片说明

When you start the application Visual Studio will automatically set the environment variables for you (based on settings from launchSettings.json in the properties folder). 启动应用程序时,Visual Studio将自动为您设置环境变量(基于properties文件夹中launchSettings.json中的设置)。

When you run from commandline or double-click, you need to set the environment variable yourself using setx ASPNETCORE_ENVIRONMENT "Development" (Commandline) or $Env:ASPNETCORE_ENVIRONMENT = "Development" (Powershell). 从命令行运行或双击时,需要使用setx ASPNETCORE_ENVIRONMENT "Development" (命令行)或$Env:ASPNETCORE_ENVIRONMENT = "Development" (Powershell) setx ASPNETCORE_ENVIRONMENT "Development"设置环境变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM