using Microsoft.AspNetCore.Mvc; using Microsoft.Data.SqlClient; namespace WebApplication1.Controllers { [ApiController] [Route("[controller]")] public class WeatherForecastController : ControllerBase { static public SqlConnection SqlConnection = new SqlConnection("Data Source=ngknn.ru;Initial Catalog=AAAnobldemo;User ID=21p;Password=12357;Connect Timeout=30;Encrypt=False;Trust Server Certificate=True;Application Intent=ReadWrite;Multi Subnet Failover=False"); [HttpGet(Name = "GetWeatherForecast")] public List GetRegion() { SqlConnection.Open(); SqlCommand sqlCommand = new SqlCommand("select NameRegion from Region", SqlConnection); List list = new List(); SqlDataReader reader = sqlCommand.ExecuteReader(); while (reader.Read()) { list.Add(reader.GetString(0)); } SqlConnection.Close(); reader.Close(); return list; } } }