0

ネット通常、phpで以前のフォームから値を取得しようとしています。これは次のように記述されます

$name= $_POST ["Username"];
$pass= $_POST ["Password"]; 

どうすればこれをasp.netに書くことができますか

4

3 に答える 3

1

GET を使用する場合

string usrnm = Request.QueryString["username"];
string pass = Request.QueryString["password"];

POST を使用する場合

 string usrnm = Request.Form["username"];
 string pass = Request.Form["password"];
于 2012-06-23T07:32:53.123 に答える
0

そのため、モデルバインディングが優れているmvcを使用します。

したがって、モデルバインディングが優れているMVCを使用しています。適切なモデルオブジェクトを作成するだけです。あなたの例のために

public class LoginInfo()
{
    public string UserName{get;set;}
    public string Password {get;set;}
}

コントローラーで

[HttpPost] 
public ActionResult Logon(LoginInfo loginInfo )
{
   // Do stuff with loginInfo
}
于 2012-06-23T07:37:34.497 に答える
0

ウェブフォームで

if (Page.IsPostBack)
{
  //access posted input as
    Request.Form["input1"]
    Request.Form["input2"]
    Request.Form["input3"]
}

mvcで

[HttpPost]
 public ActionResult myaction(strig input1,strig input1,strig input1)
        { 
            //you can access your input here
            return View();
        }

または、3つの入力を受け取ることができるビューモデルがある場合

public class myViewmodleclass()
{
    public string input1{get;set;}
    public string input2{get;set;}
    public string input3{get;set;}
}

コントローラーアクション

[HttpPost]
public ActionResult myaction(myViewmodleclass mymodelobject)
{ 
  //you can access your input here
  return View();
}
于 2012-06-23T07:30:31.300 に答える