0

I'm trying to get parameters received from a form, that were sent with method POST.

I don't know how it's called in asp, M$ loves to change stuff's names to mess with us. They come in HTTP body, while GET/QueryString parameters come in URL after the ? sign.

In PHP, "get patameters" are available in the $_GET array. In asp they are Request.QueryString["parameter1"].

"post patameters" are in $_POST, and I cant find it in asp. I hope I made it clear :p

4

3 回答 3

2

To read the value from paramater1 contained inside the form data:

string paramater1 = Request.Form["paramater1"];

Note that if the form doesn't contain your variable, paramater1 will be null.

于 2013-07-24T20:21:35.763 回答
1

Try Request.Params, it should contain all GET and/or POST parameters, Request.Form should contain only form parameters.

于 2013-07-24T20:22:08.587 回答
1

假设您的查询字符串是这样的:

http://stackoverflow.com/questions.aspx?id=17844065&title=post-parameters-in-asp-net

如果我是对的,那么你正在寻找这个。请注意这是关于 ASP.Net,我不知道经典的 ASP。我相信这不适用于经典的 ASP。

你可以在cs中使用,

if(Request["id"]!=null )
{
  var id= Request["id"]; // gives you id as 17844065 string values
}


if(Request["title"]!=null )
{
  var title= Request["title"]; // gives you title as string 
}

更新 :

NameValueCollection nvc = Request.Form;
string userName, password;
if (!string.IsNullOrEmpty(nvc["txtUserName"]))
{
  userName = nvc["txtUserName"];
}

if (!string.IsNullOrEmpty(nvc["txtPassword"]))
{
  password = nvc["txtPassword"];
}
于 2013-07-24T21:05:19.063 回答