-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
I am using a Blazor web assembly with ASP.NET Core hosted.
I have set Base URL to "/"
I want to convert the image from a URL to byte array
So I am using below code to convert
string imageUrl = "https://homepages.cae.wisc.edu/~ece533/images/frymire.png"; var imageBytes = await File.ReadAllBytesAsync(imageUrl);
But Blazor Web Assembly gives following error on runtime
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Could not find a part of the path "/https:/homepages.cae.wisc.edu/~ece533/images/frymire.png". System.IO.DirectoryNotFoundException: Could not find a part of the path "/https:/homepages.cae.wisc.edu/~ece533/images/frymire.png". at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) <0x2de83f8 + 0x00258> in <filename unknown>: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 options) <0x35ad778 + 0x0001c> in <filename unknown>:0 at System.IO.File.ReadAllBytesAsync (System.String path, System.Threading.CancellationToken cancellationToken) <0x35a9718 + 0x0003a> in <filename unknown>:0 at SlashCare.Client.Pages.Admin.Category.CategoryComponent.EditCategoryOpenAsync (System.Guid categoryId) [0x0011f] in D:\Projects\SlashCare\Client\Pages\Admin\Category\CategoryComponent.razor.cs:72 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion (System.Threading.Tasks.Task task) <0x2f9d710 + 0x000da> in <filename unknown>:0 at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask (System.Threading.Tasks.Task taskToHandle) <0x2f9a270 + 0x000b6> in <filename unknown>:0
As I can see in the error / is automatically appended to the path which causes this issue
Any solution to this issue?