我真的不知道如何寻找我想要实现的目标.我将添加两张图片,以更好的方式向您展示我在这里所做的事情.
正如您所看到的,我在防火墙中添加了一个阻止规则,该规则将阻止特定应用程序的一系列地址(第二个图像的第一个规则).
有没有办法在Windows手机上做类似的事情?我不是在寻找一些代码或任何东西.只是为了一些指导.我应该在哪里看?我应该寻找什么?Windows手机没有防火墙,我不想使用任何外部防火墙应用程序,如果有...
有没有办法获取ReadAsStringAsync()方法的进度?我只是获取网站的 HTML 内容并进行解析。
public static async Task<returnType> GetStartup(string url = "http://")
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("User-Agent",
"Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko");
using (HttpResponseMessage response = await client.GetAsync(url))
{
using (HttpContent content = response.Content)
{
string result = await content.ReadAsStringAsync();
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将内容发布到我的服务器。这就是我过去一直这样做的方式,直到我不得不使用字符串以外的对象为止。
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(authType, tokens);
var postParams = new Dictionary<string, object>();
postParams.Add("string", string);
postParams.Add("int", string);
postParams.Add("datetime", DateTime);
postParams.Add("datetime", DateTime);
postParams.Add("Match", Match);
postParams.Add("TicketId", token);
using (var postContent = new FormUrlEncodedContent(postParams.ToDictionary()))
{
var myContent = JsonConvert.SerializeObject(postParams);
var buffer = System.Text.Encoding.UTF8.GetBytes(myContent);
var byteContent = new ByteArrayContent(buffer);
byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
using (HttpResponseMessage response = await client.PostAsync(@"http://url/api", byteContent))
{
response.EnsureSuccessStatusCode(); // Throw if httpcode is an error
using (HttpContent content = response.Content)
{
string result = …Run Code Online (Sandbox Code Playgroud) c# ×3
httpclient ×2
async-await ×1
asynchronous ×1
encoding ×1
firewall ×1
http ×1
ip-address ×1
json ×1
stream ×1