问题是,当我点击IISExpress启动调试时,出现了以下错误: 这些是项目属性 Debug
![property1](https://istack.dev59.com/PlWCF.webp)
编辑 这是我的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();
});
}
}
}
这是我的控制器的片段(但后端从不停在这里)。
namespace backendCore.Controllers
{
public class AuthController : ControllerBase
{
[Route("api/Auth/{language}/guest")]
[HttpPost]
public ActionResult guestAuth(string language)
{
return Ok(true);
}
}
http://localhost:8083/backend
。因此,预计会出现404错误。您需要学习路由并了解此Web应用程序所期望的正确URL。 - Lex LilaunchSettings.json
文件中看到了后缀backendCore
,要启动的路由后缀是backend
还是backendCore
? - Antonio Leonardo