.net - Blazor BaseURI http 与 https 问题

标签 .net asp.net-core .net-core blazor

我在 Heroku 中托管了示例服务器端 Blazor 应用程序。

https://blazor-server.herokuapp.com

在页面之间切换时,它默认为页面的 http 版本,因此会出现如下错误:

blazor.server.js:8 Uncaught (in promise) Error: System.ArgumentException: The URI 'https://blazor-server.herokuapp.com/counter' is not contained by the base URI 'http://blazor-server.herokuapp.com/'.

最佳答案

将以下命令添加到配置方法似乎已经解决了这个问题:

  app.UseForwardedHeaders();
    app.Use((ctx, next) =>
    {
        ctx.Request.Scheme = "https";
        return next();
    });

关于.net - Blazor BaseURI http 与 https 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56543018/

相关文章:

c# - 在 C# 中处理相互引用的多个对象

c# - 验证元素的未转义长度

c# - 停止由 CancellationToken 生成的异常被 ApplicationInsights 报告

c# - 如何在 Entity Framework Core 中从 appsettings.json 设置连接字符串

c# - 获取存储库设计模式中的表名

c# - 我如何 "ASCII armor"我的 MemoryStream?

asp.net - 如何在 ASP.NET Core-SPA 应用程序上禁用服务器端渲染?

c# - 是否可以在 ASP.NET Core 中组合 [FromRoute] 和 [FromBody]?

c# - ASP.NET Core 2 中的依赖注入(inject)抛出异常

c# - 从 JSON 中反序列化属性两次?