代码之家  ›  专栏  ›  技术社区  ›  VAAA

c#webrequest发布表单数据

  •  1
  • VAAA  · 技术社区  · 7 年前

    我有一个邮递员,他使用表单数据向网站发送成功的电话:

    enter image description here

    如何使用与c#中的postman相同的表单数据进行发布?

    我正在做但不工作。

    string formParams = string.Format("Email={0}&Password={1}&ufprt={2}", "123@gmail.com", "test", key);
                    string cookieHeader;
    
    
                    getRequest = WebRequest.Create(baseaUrl);
                    getRequest.ContentType = "application/form-data";
                    getRequest.Method = "POST";
    
                    byte[] bytes = Encoding.ASCII.GetBytes(formParams);
                    getRequest.ContentLength = bytes.Length;
                    using (Stream sr = getRequest.GetRequestStream())
                    {
                        sr.Write(bytes, 0, bytes.Length);
    
                    }
    
                    getResponse = getRequest.GetResponse();
    

    谢谢

    0 回复  |  直到 7 年前