I have a blazor WASM application with 3 projects: Client, Server, Shared.
As a simplistic example, I'd call my API from the client via:
var result = await http.GetAsync($"{controller}/GetAllItems");On the server side my API is defined as:
[ApiController][Route("[controller]/[action]")]public class ItemController : Controller [HttpGet] public async Task<ActionResult<List<POCO>>> GetAllItems() { var items = await repository.GetItems(); return Ok(items); } This code has been working fine for two weeks. Until today, when it stopped working. After debugging, I found that the name: GetAllItems no longer worked.
Once I changed the method name from GetAllItems to GetAllItemsNew, the code worked fine again.
A few hours later, this happened a second time with another method.
Is there a reason why the blazor API would stop routing to specific method names, but continue to work for others?
EDIT
Following the advice in the comments, I installed Postman. I'm unable to connect to my API via Postman. In my app:
- I added App.UseAuthentication to StartUp.Configure()
- I flagged the Controller as [AllowAnonymous]
- I started running the app in Debug Mode from Visual Studio
In Postman
- I disabled SSL certificate verification
- I performed a GET to localhost:44383/ItemController/GetAllItems
I got back the following error:
<!DOCTYPE html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /><title>TestApp</title><base href="/" /><link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" /><link href="css/app.css" rel="stylesheet" /><link href="TestApp.Client.styles.css" rel="stylesheet" /></head><body><div id="app">Loading...</div><div id="blazor-error-ui"> An unhandled error has occurred.<a href="" class="reload">Reload</a><a class="dismiss">🗙</a></div><script src="_framework/blazor.webassembly.js"></script></body></html>