F A*_*rei 5 asp.net asp.net-mvc asp.net-core-mvc asp.net-core
当我将网站作为控制台应用程序运行时,我想更改默认URL(http:// localhost:5000)。
我编辑了launchSettings.json但它不起作用...它仍然使用端口5000:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4230/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"website": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:80",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 6
您需要在构建“BuildWebHost”时添加 url。希望这对您有帮助https://github.com/aspnet/KestrelHttpServer/issues/639
下面是我在 .net core 2.0 控制台应用程序中使用的代码
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://localhost:5050/")
.Build();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9631 次 |
| 最近记录: |