peirix
peirix

Reputation: 37771

ASP.NET's equivalent of PHP's $_GET and $_POST?

As thet title says.

I'm new to asp.net, and I'm sorta trying to build some AJAX-stuff to learn.

Upvotes: 5

Views: 9223

Answers (4)

JB King
JB King

Reputation: 11910

ASP.Net AJAX may also be worth reading as there are some built-in things that could be useful.

"Request.QueryString" and "Request.Form" are the likely answers to the title question.

Upvotes: 6

Igor Zevaka
Igor Zevaka

Reputation: 76570

Request object is a map of all the request headers - both from the POST request and URL encoded params:

//This will retrieve the value of "SomeHeader" from the request
//e.g. http://localhost/page.aspx?SomeHeader=thisisvalue
string value = HttpContext.Current.Request["SomeHeader"];
//value == "thisisvalue"

Upvotes: 0

Jason Whitehorn
Jason Whitehorn

Reputation: 13685

Following up with marr75's response, the Request property exposes a dictionary of GETed and POSTed variables.

Upvotes: 1

marr75
marr75

Reputation: 5725

See http://msdn.microsoft.com/en-us/library/swe97x0b.aspx.

It explains how to access the response and request context. If you're going to do ajax stuff, you might want to think about WCF REST, in which case, it's totally different and I would recommend going through some tutorials to see how the http elements of the application are abstracted away. In any event, in a lot of ASP.NET development, you don't touch the response and request contexts directly.

Upvotes: 0

Related Questions