The error is occuring in the getStores() function:
An unhandled exception occurred while processing the request. ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'
public class StoreController : Controller
{
// dependency-injected
private readonly MySqlConnection _connection;
public StoreController(MySqlConnection mySqlConnection)
{
_connection = mySqlConnection;
}
// GET
public IActionResult Index()
{
return Content("home");
}
[HttpPost]
[Route("/stores")]
public async Task getStores()
{
// open connection
await _connection.OpenAsync();
// execute query and get stores
using var command = new MySqlCommand("SELECT * FROM Stores", _connection);
using var reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
var value = reader.GetValue(0);
Console.WriteLine(value);
}
}
}