I am trying to make a request from my Razor code to my controller and return my one row I know I have in my DB.
The Scoop - I make the GET call in my Razor -> It goes to GET in my controller, where I KNOW it returns my one DB row. So everything looks fine on the back end. THEN I return that back to my frontend BUT the data from the GET to my controller is not there,
instead it just contains the original data I put in the object.
This is a Blazor Web Assembly app so I have done all debugging in the browser for the front end stuff and VS for anything back end to see what is going on. BUT I can't figure out what the deal is here...
Whats going on here????
/*Razror C#*/
private List<Items> items;
private int Id { get; set; } = 0;
private string Name { get; set; } = "";
private string Description { get; set; } = "";
None
0 Points
1 Post
Blazor Web Assembly App GET request not flowing back to UI
Mar 14, 2020 12:26 AM|GhostLegs27|LINK
I am trying to make a request from my Razor code to my controller and return my one row I know I have in my DB.
The Scoop - I make the GET call in my Razor -> It goes to GET in my controller, where I KNOW it returns my one DB row. So everything looks fine on the back end. THEN I return that back to my frontend BUT the data from the GET to my controller is not there, instead it just contains the original data I put in the object.
This is a Blazor Web Assembly app so I have done all debugging in the browser for the front end stuff and VS for anything back end to see what is going on. BUT I can't figure out what the deal is here...
Whats going on here????
/*Razror C#*/
private List<Items> items;
private int Id { get; set; } = 0;
private string Name { get; set; } = "";
private string Description { get; set; } = "";
protected override async Task OnInitializedAsync()
{
items = await Http.GetJsonAsync<List<Items>>(APIServer);
//value - 0
int testID = items.ElementAt(0).Id;
value - "" string
testNAME = items.ElementAt(0).Name;
value - "" string
testDES = items.ElementAt(0).Description; }
....
/*Controller*/
[HttpGet] public async Task<IEnumerable<Item>> GetAsync()
{
List<Item> currentIems= new List<Item>();
currentItems = await _dbContext.Item.ToListAsync();
//this DOES in fact return my 1 row I have in the DB return
currentItems;
}