我的dotnetcoreapp2.2应用程序在port 5001下运行良好(在配置了dev证书之后),但是我无法让它在任何其他端口下启动。以下是我尝试配置的组件..。
Program.cs:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://localhost:5000")
.UseKestrel()
.UseStartup<Startup>()
.UseApplicationInsights();Startup.cs:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseAuthentication();
if (env.IsDevelopment() || env.IsEnvironment("Developer"))
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
}launch.json:
"args": [
"--urls", "http://localhost:5000"
],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Developer",
"ASPNETCORE_URLS": "http://localhost:5000"
},我是不是漏掉了什么东西,还是配置得不正确?
发布于 2019-07-24 12:32:25
此问题通常发生在使用IIS / IIS Express时,因此不使用IIS。
将web服务器作为.net核心控制台应用程序运行,而不是使用instead (它对每个项目都有自己的端口配置文件,而且很烦人)。
:在Project's Properties > Debug >中更改调试配置文件
Profile的值从IIS更改为"select-your-project-name“Launch的值从IIS或IIS更改为ProjectWeb Server Settings,您可以使用它来更改端口(IIS不再使用)。IIS Express更改为"select-your-project-name“(您将看到单击哪里来调试项目)https://stackoverflow.com/questions/57182340
复制相似问题