通过托管环境为自托管 [英] Pass hosting environment for self-hosting

查看:150
本文介绍了通过托管环境为自托管的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行ASP.NET核心(.NET 4.6.1)的应用程序通过的 weblistener

I'm trying to run ASP.NET Core (.NET 4.6.1) application as self hosting by means of weblistener

我已经添加一个命令:

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

和必要的依赖关系。 JSON

and necessary dependencies in project.json

当我开始通过Visual Studio中我的应用程序是正常工作

When I start my application via Visual Studio it's works fine

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

ProjectName.exe开始为Web服务器托管环境:开发

ProjectName.exe starts as web server with Hosting environment: Development

但是,当我用手运行它 ProjectName.exe 主机运行环境:生产键,它不能正常工作。
我只想找到路与开发环境

But when I run it by hand ProjectName.exe runs with Hosting environment: Production and it's not working properly. First of all I want find way to run application by hand with Development environment

在VS我跑手申请的第一有此选项:

In VS I have this option:

推荐答案

当你启动应用程序的Visual Studio将自动设置环境变量为你(基于文件夹的属性从launchSettings.json设置)。

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).

当您从命令行或双击运行,则需要使用 SETX ASPNETCORE_ENVIRONMENT发展(命令行)或 $ ENV:ASPNETCORE_ENVIRONMENT =发展(PowerShell的)

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).

这篇关于通过托管环境为自托管的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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