Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to traverse through Request.Form without knowing any details?

I want to spit out everything in Request.Form so I can just return it as a string and see what I am dealing with. I tried setting up a for loop...

// Order/Process
// this action is the submit POST from the pricing options selection page
// it consumes the pricing options, creates a new order in the database,
// and passes the user off to the Edit view for payment information collection

[AcceptVerbs(HttpVerbs.Post)]
public string Process()
{
    string posted = "";
    for(int n = 0;n < Request.Form.Count;n++)
        posted += Request.Form[n].ToString();
    return posted;
}

But all I ever get back is '12' and I know there are a lot more things on the form than that...

like image 718
MetaGuru Avatar asked Sep 29 '09 15:09

MetaGuru


1 Answers

StringBuilder s = new StringBuilder();
foreach (string key in Request.Form.Keys)
{
    s.AppendLine(key + ": " + Request.Form[key]);
}
string formData = s.ToString();
like image 54
D'Arcy Rittich Avatar answered Oct 16 '22 17:10

D'Arcy Rittich