我使用 Visual Studio 创建了一个 Asp.Net Core 应用程序,并使用 VS 的发布选项在我的 Azure 帐户上发布我的应用程序。
发布后,我使用该链接访问我的网站,但收到“HTTP 错误 500.30 - ASP.NET Core 应用程序无法启动”
我转到 Azure 中的控制台手动启动我的应用程序并了解有关该问题的更多详细信息,然后我得到了这个。
不太确定如何解决我的端口的这个问题
下面是program.cs中的代码
var connectionString = builder.Configuration.GetConnectionString("LocalConnection");
builder.Services.AddDbContext<LotharDataBaseContext>(options =>
options.UseSqlServer(connectionString));
builder.Services.AddControllersWithViews();
builder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
.AddNegotiate();
builder.Services.AddAuthorization(options =>
{
// By default, all incoming requests will be authorized according to the default policy.
options.FallbackPolicy = options.DefaultPolicy;
});
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
最佳答案
通过你的截图,我看到了Kestrel,所以我想,你创建的web应用程序应该在linux平台上。屏幕截图上的端口占用是预期行为,它不应该是根本原因。由于该站点已经在运行,并且您手动命令它重新启动,因此应该会出现此错误。
我建议您先提供您的 Program.cs 文件,我们需要查看 UseUrls 或 UseKestrel 的代码。
如何在启动webapp时检查日志:
打开您的 kudu 网站,网址应为
https://your_app_name.scm.azurewebsites.net
打开 newui,
https://your_app_name.scm.azurewebsites.net/newui
步骤:
- 在这个default_docker.log文件中,我们将得到有用的消息。
您可以尝试的步骤:
尝试添加
.UseIIS
,我们知道您的平台是linux。删除
.UseUrls()
,并重新部署您的网络应用。
关于c# - 如何解决 "Failed to bind to address http://127.0.0.1:5000: address already in use.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71592915/