I have a webpage which has a big form(100 rows and 100 columns) and I want to post some data to that web site with a Post Request. But when i look Fiddler, this post request's content type is "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryZGLjsQc0BHm6iDFX". And here is some of the post data in this post request;
------WebKitFormBoundaryZGLjsQc0BHm6iDFX
Content-Disposition: form-data; name="__VIEWSTATE"
W+jXmq1XPrLQXBiZKXge8D3Wwt4Y4KkBWoYscKGMFVHVWIUFEP7rKy5k+T1rCleJWd9BNH1N+fad4qAPu5EYQDbywOhQ9vb6OcxwBhgktW//be6Bf67kq+yT34l8vipo
------WebKitFormBoundaryZGLjsQc0BHm6iDFX
Content-Disposition: form-data; name="__VIEWSTATEGENERATOR"
2399BEAA
And here is my post method:
public static string Post(string url, string referer, string postData, CookieContainer cookies, string contentType, string accept)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.CookieContainer = cookies;
req.Referer = referer;
req.UserAgent = "";
req.ContentType = contentType;
req.Accept = accept;
req.ContentLength = postData.Length;
req.AllowAutoRedirect = false;
Stream postStream = req.GetRequestStream();
byte[] postBytes = Encoding.ASCII.GetBytes(postData);
postStream.Write(postBytes, 0, postBytes.Length);
postStream.Dispose();
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
cookies.Add(resp.Cookies);
StreamReader reader = new StreamReader(resp.GetResponseStream());
string src = reader.ReadToEnd();
reader.Dispose();
return (src);
}
So is there any way on C# to create my postData in multipart/form-data format ?
Big thx for the answers. Regards.