| | |
| | | public class CreateModel : PageModel |
| | | { |
| | | private readonly ILogger<CreateModel> _logger; |
| | | private readonly HttpClient _httpClient; |
| | | private readonly IHttpClientFactory _httpClientFactory; |
| | | |
| | | public CreateModel(ILogger<CreateModel> logger, IHttpClientFactory httpClientFactory) |
| | | { |
| | | _logger = logger; |
| | | _httpClient = httpClientFactory.CreateClient(); |
| | | _httpClient.BaseAddress = new Uri($"{Request.Scheme}://{Request.Host}"); |
| | | _httpClientFactory = httpClientFactory; |
| | | } |
| | | |
| | | [BindProperty] |
| | |
| | | |
| | | try |
| | | { |
| | | // 创建HttpClient并设置BaseAddress |
| | | var httpClient = _httpClientFactory.CreateClient(); |
| | | httpClient.BaseAddress = new Uri($"{Request.Scheme}://{Request.Host}"); |
| | | |
| | | var config = new InstanceConfig |
| | | { |
| | | Id = Input.Id, |
| | |
| | | } |
| | | }; |
| | | |
| | | var response = await _httpClient.PostAsJsonAsync("/api/SimulatorInstances", config); |
| | | var response = await httpClient.PostAsJsonAsync("/api/SimulatorInstances", config); |
| | | |
| | | if (response.IsSuccessStatusCode) |
| | | { |