Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 3954

Blazor requesting a json file

$
0
0

I am trying to retrieve data from the server. But I can't get the json file from the server. I placed my json file in wwwroot/data/Users.json. This is my code. I receive this exception: Unhandled exception rendering component: Could not find a part of the path "/data/Users.json".

@page "/"@code{    public class User    {        public string username;        public string password;    }}@{     string json = System.IO.File.ReadAllText("data/Users.json");    User mahan = Newtonsoft.Json.JsonConvert.DeserializeObject<User>(json);<body><h1>Usernsme: @mahan.username</h1></body>

Viewing all articles
Browse latest Browse all 3954

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>