App_Code/HttpService.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net;
using System.Web;

/// <summary>
/// HttpService 的摘要说明
/// </summary>
public class HttpService
{

    public static string Get(string url)
    {
        using (WebClient c = new WebClient())
        {
            try
            {
                c.Encoding = System.Text.Encoding.UTF8;
                return c.DownloadString(url);
            }
            catch (Exception)
            {
                throw;
            }
        }
    }


    public static string GetPost(string url, string parameters)
    {
        string ret = "";
        using (WebClient c = new WebClient())
        {
            try
            {
                c.Encoding = System.Text.Encoding.UTF8;
                byte[] data = System.Text.Encoding.UTF8.GetBytes(parameters);
                c.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                c.Headers.Add("ContentLength", parameters.Length.ToString());
                ret = System.Text.Encoding.UTF8.GetString(c.UploadData(url, "POST", data));
                return ret;
            }
            catch (Exception)
            {
                throw;
            }
        }
    }


    public static string GetPost(string url, NameValueCollection nv)
    {
        using (WebClient c = new WebClient())
        {
            try
            {
                c.Encoding = System.Text.Encoding.UTF8;
                return System.Text.Encoding.UTF8.GetString(c.UploadValues(url, "POST", nv));
后面还有 9 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。