gpt4 book ai didi

asp.net-core - 在 Visual Studio 中调试 ASP.NET Core 应用程序

转载 作者:行者123 更新时间:2023-12-04 13:08:31 25 4
gpt4 key购买 nike

我在我的解决方案中创建了一个新项目。该项目是 ASP.NET Core 应用程序。

问题是当我点击 IISExpress iis express lounch button开始调试我有这个错误:

error

这些是项目属性Debug property1

property2

我不知道该怎么办...有人可以帮助我吗?


编辑这是我的 launchSettings.json

{
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": true,
"iis": {
"applicationUrl": "http://localhost:8083/backendCore",
"sslPort": 0
},
"iisExpress": {
"applicationUrl": "http://localhost:8083",
"sslPort": 0
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "backend",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"backendCore": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
"prova": {
"commandName": "IIS",
"launchBrowser": true,
"launchUrl": "backend"
}
}
}

和startup.cs

namespace backendCore
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UsePathBase("/backend"); //Add this line
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

这是我的 Controller 的片段(但后端永远不会在这里停止)

namespace backendCore.Controllers
{
public class AuthController : ControllerBase
{
[Route("api/Auth/{language}/guest")]
[HttpPost]

public ActionResult guestAuth(string language)
{
return Ok(true);
}

}

最佳答案

startup.cs 文件Configure 方法中更改以下代码

if (env.IsDevelopment())
{
app.UsePathBase("/backend"); //Add this line
app.UseDeveloperExceptionPage();
}

这添加了一个中间件,它从请求路径中提取指定的路径库并将其后置到请求路径库中。这只针对开发环境,如果你的生产环境也配置了backend子文件夹,把它放在if条件之外。

关于asp.net-core - 在 Visual Studio 中调试 ASP.NET Core 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68242885/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com