azure - 我创建了一个带有 HttpGet 请求的 Blazor Web Assembly 应用程序,该应用程序在本地工作,但一旦发布到 Azure 就会失败
问题描述
我创建了一个带有 Httpget 请求的 Blazor Web 程序集应用程序。它在本地运行良好,但是当作为 ASP.NET 托管发布到 Azure 应用服务时,Httpget 请求失败并出现以下错误:
System.Text.Json.JsonReaderException:“<”是一个无效的值开始。行号:0 | BytePositionInLine: 0. 在 System.Text.Json.ThrowHelper.ThrowJsonReaderException (System.Text.Json.Utf8JsonReader& json, System.Text.Json.ExceptionResource 资源, System.Byte nextByte, System.ReadOnlySpan`1[T] 字节) <0x2a486d8 + 0x00020> in <515164c3ada14b86914aa92e915c4401>:0 at System.Text.Json.Utf8JsonReader.ConsumeValue (System.Byte marker) <0x2682800 + 0x00260> in <515164c3ada14b86914aa92e915c4401>:0 at System.Text.Json.Utf8JsonReader.ReadFirstToken (System.Byte第一个)<0x2681ad8 + 0x001ae> 在 <515164c3ada14b86914aa92e915c4401> 中:0 在 System.Text.Json.Utf8JsonReader.ReadSingleSegment () <0x26814d0 + 0x001fe> 在 <515164c3ada14b86914aa92e915>.c 中
// 在列表中创建我的数据
public class ConfiguratorRepo
{
public List<Configurator> GetConfigurators()
{
Configurator Icfs = new Configurator
{
Name = "My test",
ID = 99,
Description = "Desc"
};
List<Configurator> Icf = new List<Configurator>
{
Icfs
};
return Icf;
}
}
// 设置 HttpGet
[ApiController]
[Route("[controller]")]
public class ConfiguratorController : ControllerBase
{
[HttpGet]
[Route("GetAll")]
public IList<Configurator> Get()
{
ConfiguratorRepo repo = new ConfiguratorRepo();
return repo.GetConfigurators();
}
}
//在我的 .razor 页面的代码部分中
protected override async Task OnInitializedAsync()
{
try
{
Configurators = await Http.GetJsonAsync<List<Configurator>>("Configurator/GetAll");
}
catch (Exception e)
{
Error = e.InnerException.ToString();
}
}
这是项目的链接https://1drv.ms/u/s!As_wHGs2IYp0kgsfcf970zD53Vvt?e=mnPrph
有什么想法吗?
解决方案
推荐阅读
- python - 无法在 python 中使用 lxml 从 XML 正确获取预期项目
- rhel8 - 重新启动:加载共享库时出错:libip4tc.so.2:无法打开共享对象文件:没有这样的文件或目录
- python-3.x - 如何将输出放在一行中?
- android - 从库模块中删除未使用的类
- ansible - 如何使用 Ansible 同时遍历主机和设置变量
- bubble-sort - 修改冒泡排序以防止额外比较
- node.js - 如何将预定义的函数回调转换为 Promise
- postgresql - 使用 postgresql 字段类型文本过滤 kafka 消息时出错
- android - 如何在不引用它的情况下删除 firebase 事件侦听器?
- c - 在 C++ 中无状态地包装 C 回调接口