December 8, 2024
avaloniaui 打包windows
参考
dotnet publish CountDown.sln -c Release -r win-x64 /p:PublishSingleFile=true /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishReadyToRunShowWarnings=true /p:UseAppHost=true /p:IncludeNativeLibrariesForSelfExtract=true /p:SelfContained=true --self-contained true
December 8, 2024
C#开发笔记
#
网络请求
#
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.Json.Nodes;
string cookie = "";
var handler = new HttpClientHandler();
using (var httpClient = new HttpClient(handler))
{
using (var request = new HttpRequestMessage(new HttpMethod("POST"), new Uri("https://cloud.yibailingshou.com/wsy_user/web/index.php?m=login&a=register_get_phone_code")))
{
var multipartContent = new MultipartFormDataContent();
multipartContent.Add(new StringContent("17628818007"), "phone");
multipartContent.Add(new StringContent("czo0OiI5NTY1Ijs"), "customer_id");
multipartContent.Add(new StringContent("+86"), "country_code");
multipartContent.Add(new StringContent(""), "captcha_token");//post data
request.Headers.TryAddWithoutValidation("X-Requested-With", "XMLHttpRequest");//添加header
request.Content = multipartContent;
using (var response = await httpClient.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);// 响应正文
Console.WriteLine(response);
if (response.Headers.TryGetValues("Set-Cookie", out IEnumerable<string> cookieValues))
{
string ck = cookieValues.FirstOrDefault();//响应header中的Set-cookie
Console.WriteLine(ck.Split(";")[0]);
}
dynamic result = JsonNode.Parse(body)!;//json解析
if (result["errcode"].GetValue<int>() == 407)// json对象取值
{
//return "407";
}
else if (result["errcode"].GetValue<int>() == 0)
{
//return "0";
}
else
{
//return "false";
}
}
}
}
AES加密
#
解密反之,易写
...