我正在使用托管 ASP.NET Core 的 Blazor Web 程序集。我已将基本 URL 设置为“/”
我想将图像从 URL 转换为字节数组所以我使用下面的代码进行转换
string imageUrl = "https://homepages.cae.wisc.edu/~ece533/images/frymire.png";
var imageBytes = await File.ReadAllBytesAsync(imageUrl);
但是 Blazor Web Assembly 在运行时会出现以下错误
blazor.webassembly.js:1 暴击:Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] 未处理的异常渲染组件:找不到路径的一部分“https://homepages.cae.wisc.edu/~ece533 /images/frymire.png”。System.IO.DirectoryNotFoundException:找不到路径“/https:/homepages.cae.wisc.edu/~ece533/images/frymire.png”的一部分。在 System.IO.FileStream..ctor(System.String 路径、System.IO.FileMode 模式、System.IO.FileAccess 访问、System.IO.FileShare 共享、System.Int32 bufferSize、System.Boolean 匿名、System.IO。 FileOptions options) <0x2de83f8 + 0x00258> in :0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize,System.IO.FileOptions 选项)<0x35ad778 + 0x0001c>
正如我在错误中看到的那样 / 自动附加到导致此问题的路径
这个问题有什么解决办法吗?