Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c#: get values posted from a form [duplicate]

Tags:

c#

post

forms

Im posting some data from another page using a form with the method post. What i would like to know is: Whats the best way to get the values. Going by eacn name in the form as

Request["name"]

Or is there any way to get a collection of the data and itterate through it? Thanks

like image 281
Johan Avatar asked Dec 18 '25 10:12

Johan


1 Answers

You can write

foreach (string key in Request.Form)

You may also want if (Request.HttpMethod == "POST") or if (Request.Form.Count > 0)

like image 196
SLaks Avatar answered Dec 19 '25 22:12

SLaks



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!