Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fake Http post?

I am using asp.net mvc and I want to fake a http post to see what would happen. Is there any software that I can use?

like image 930
chobo2 Avatar asked Apr 09 '26 06:04

chobo2


2 Answers

I believe that Fiddler allows you to do this, plus a whole lot more.

I only use it for reviewing what's going to/from the server when dealing with AJAX induced headaches, but I'm fairly sure you can use it to re-issue HTTP requests both as they were originally and modified, which should fit the bill for you.

like image 105
Rob Avatar answered Apr 11 '26 20:04

Rob


string var1 = "Foo";
string var2 = "Bar";

ASCIIEncoding encoding = new ASCIIEncoding();
string post = "var1=" + var1 + "&var2=" + var2;
byte[] bites = encoding.GetBytes(post);

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://Url/PageToPostTo.aspx");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = bites.Length;
Stream s = request.GetRequestStream();
s.Write(bites, 0, bites.Length);
s.Close();
like image 45
Timothy Lee Russell Avatar answered Apr 11 '26 18:04

Timothy Lee Russell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!