- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
创建了一个新的 ASP.NET Core 2.0 项目,它在本地运行良好。然后在本地的 Docker 容器中运行它后,它也可以正常工作。但是当我尝试在 Kubernetes pod 中使用 Docker 镜像时,它会运行几分钟,然后给我这个:
Unhandled Exception: System.InvalidOperationException: A path base can
only be configured using IApplicationBuilder.UsePathBase().
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.
<BindAddressAsync>d__7.MoveNext()
这是我的Program.cs
:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
Startup.cs
:
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.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = true,
ReactHotModuleReplacement = true
});
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
}
}
最佳答案
发生此错误时,我们使用 FROM microsoft/aspnetcore-build:1.1
基础镜像作为构建和运行时。在我们遇到错误时,我们只是尝试升级到 FROM microsoft/aspnetcore-build:2.0
。我不确定这张图片的具体问题是什么,但 Kubernetes 不喜欢它。
稍后,我们将 dockerfile 切换为多阶段;使用 FROM microsoft/aspnetcore-build:1.1
构建并使用 FROM microsoft/dotnet:1.1-runtime
运行,当我们将其升级到相应的 2.0 版本时,我们没有不会再遇到这个错误了。
关于docker - ASP.NET Core 2.0 在 Kubernetes 中启动 Kestrel 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46351129/
我曾尝试在 net.core 文档(问题等)上搜索信息但没有结果。 代码更简单: [HttpGet()] [Route("dob")] public string dobTes
对于部署在单个 AWS EC2 主机上的 .NET Core 2.2 应用程序,我比较了 IIS 托管与普通 Kestrel 托管。 对于 IIS 配置,我遵循 MS documentation .
我使用.net core 2.1并将其发布到IIS 8.5。我很难理解 .NET 核心托管的概念。 program.cs 是 public class Program { public sta
我有一个新的 ASP.NET 5 项目并按如下方式设置 project.json; "frameworks": { "dnx451": { "dependencies
我正在努力完成以下任务:我有一个运行 gRPC 服务的 asp.net core 3.1。 在应用程序的生命周期中,我希望能够暂停/停止端点/服务器监听/接受请求,并在一段时间后恢复它。 只是为了澄清
我已使用示例默认值在 Visual Studio 2019 中创建了无状态服务(创建新项目 -> Service Fabric 应用程序 -> 命名项目和解决方案 -> 无状态 ASP.NET Cor
我已使用示例默认值在 Visual Studio 2019 中创建了无状态服务(创建新项目 -> Service Fabric 应用程序 -> 命名项目和解决方案 -> 无状态 ASP.NET Cor
我们正在尝试使用 VSCode 在 Mac 上编写 ASP.NET 应用程序。我们已经成功安装了 VSCode、DNX、Yeoman、Node.js 和 npm,以及 the ASP.NET guid
我确实遇到了红隼的一个奇怪问题。我无法上传超过红隼 MaxRequestBodySize 的多个文件。 当我试图阅读 this.Request.Form.Files.GetFiles() 时,预期的行
官方MS-documentation说如果我想在 linux 上托管一个 ASP.NET 核心应用程序,我应该在它前面放置一个 apache 或 nginx 反向代理。但是,我找不到任何我应该这样做的
通过 HTTP 和 Visual Studio 内部它工作正常。但是,当我尝试通过 HTTPS 访问端点时,我看到了这个错误,我不完全确定如何解决这个问题: info: Microsoft.AspNe
我已完成以下操作,但仍然无效。运行 dotnet myapp.dll 仍然显示它正在监听 http://localhost:5000 . 创建hosting.json 代码: { "server.
我正在尝试使用 kestrel 创建 Web 应用程序。本文中https://learn.microsoft.com/pl-pl/aspnet/core/fundamentals/servers/ke
我知道不建议将 Kestrel Web 服务器暴露给外界,但将 Kestrel 置于 IIS 之后所损失的性能并不是一件可以轻易忽略的事情。 (事实上 ,迁移到 .net core 可能会失去所有
我在带有 VS2017 (15.3.5) 的 Win 7 上使用 Asp.Net core 2.0.2。 我当前的 Kestrel 配置如下所示: return WebHost.CreateDefau
如何在 Linux/OSX 上以持久的方式运行 Kestrel 网络服务器?我能够按预期运行网络服务器: 红隼 但是,我还没有找到一种方法来让它持久化,即 k 红隼 & 进程开始然后立即停止。 最佳答
我正在学习如何在 ASP.NET Core 2 中工作,我遇到了一个相当烦人的问题。每当我运行我的应用程序时,Kestrel 服务器都会忽略我的端点配置,而是开始监听一个随机端口。不用说,这不是我所期
我们有一个 ASP.NET Core 2.x 应用程序,它实现了自定义中间件,充当另一个(基于 Java 的)服务器/应用程序前面的代理。在服务器请求完成之前,此应用程序/中间件的客户端经常中止/取消
我需要通知 systemd 我的服务已成功启动,启动后需要运行的任务要求服务器已经在监听目标 Unix域套接字。 我正在使用 IWebHost::Run 来启动服务器,这是一个阻塞调用。此外,我找不到
我有以下设置:在应用程序负载均衡器 (AWS) 后面的几个 linux 容器(基于 aspnetcore 2.0.5 构建)中运行的 web api 正在使用 HttpClient 向此 api 发出
我是一名优秀的程序员,十分优秀!