I have a ASP.Net Core hosted Blazor WASM app that makes calls to the Server API.
Most of the time, communication works completely fine, and data is exchanged without problems.
However, in some cases, the server returns the content of index.html without hitting the endpoint.
Example controller:
[HttpGet(Routes.GroupStage.GetGameDays)] // resolves to api/v1/groupstages/{id}/gamedays
public async Task<IActionResult> GetGameDays(
[FromRoute] Guid id,
CancellationToken cancellationToken)
{
var query = new GetGameDaysQuery(GroupStageId: id);
var result = await Sender.Send(query, cancellationToken);
return result.IsFailure
? HandleFailure(result)
: Ok(result.Value);
}
The really weird part is, that the controller is getting hit, if the model with a specific id does not exist. However, it is not getting hit when it actually does exist.
Is there any reason for this type of behaviour?
Changing the GetGameDays-route, (e.g. to api/v1/groupstages/{id}/gamedayss fixes the routing issue. But I would still want to know how and why this unexpected behaviour occurs.
When testing the requests in a different environment (Postman), the routing worked as expected, excluding any error on the server side. After checking the Network tab in my browser, I found out, that the request is fulfilled by (disk cache). Deactivate caching, test request ... works as expected now.
Rant incoming: Why in the world would it even do such thing? And what is the procedure there? "Hey, there maybe was a time when the controller for the given route was not there, so lets just return the fkn
index.html, no cache busting"?TLDR: Deactivate Browser caching
Related follow-up topic: Is there any 100% guaranteed way to update web applications, let alone PWAs, ensuring the latest up to date content is served without kindly asking the client's browser to not cache anything?