laatzen/Common/Ui/Common.UI/Models/HttpContext.cs
2024-12-17 10:38:42 +01:00

27 lines
790 B
C#

namespace Common.UI.Models
{
using System.Net.Http;
using System.Threading.Tasks;
public class HttpContext
{
private static readonly HttpClient httpClient = new HttpClient();
internal static async Task<string> GetEncryptionKeyAsync(string urlFormat, int serienNr)
{
var encryptionKey = default(string);
using (var httpResponeMessage = await httpClient.GetAsync(string.Format(urlFormat, serienNr)))
{
if (httpResponeMessage.IsSuccessStatusCode)
{
var content = await httpResponeMessage.Content?.ReadAsStringAsync();
encryptionKey = content?.Trim('"');
}
}
return encryptionKey;
}
}
}