As I’m new to .NET after coming from PHP I chose C# to work with and its coming along nicely.
I have a question though regarding the handling of GET and POST.
So far I’ve established that I can put this in the codefile behind the aspx page:
if (Request.HttpMethod.ToString() == "POST") {
Response.Write("You sent a post!")
}
and I could and an ELSE there to handle a GET, but how exactly would you do that?
In PHP I would do something like this:
Example URL = http://www.example.com/page.php?foo=bar
$foobar = $_GET['foo'];
Could some kind soul please give me pointers on dealing with this in C#.
Thanks
The .Net version of $_GET[] is :
You do not require to do this IF condition.
The .Net version of $_POST[] is :
Still no need the IF condition.
BUT in Asp.Net webform you do not require to use all the time Request class because the PostBack to the page will contain your form data directly into the control value. Let say you have a textbox called txt1, when the user will submit the form you can get the value of this textbox directly by accessing txt1.