![](/img/trans.png)
[英]The GET and POST with an Action in the Controller - VB.NET 2012 MVC 4
[英]$_POST['color'] for VB.NET 2012 MVC 4?
通過輸入字段提交“綠色”顏色。
現在,它需要請求它 。
在PHP中將是$_POST['color']
。
我考慮了一下,並把它寫到了這段代碼中:
對ColorName的請求-使用VB.NET 2012 MVC 4:
Public Class ColorPrintOutSubmitClassController
Inherits System.Web.Mvc.Controller
' This method will handle GET
Function PrintOutPage() As ActionResult
Return View("PrintOutPage")
End Function
' This method will handle POST
<HttpPost>
Function ColorPrintOut() As ActionResult
' Do something
Response.Write("You submitted the color: " & Request.QueryString("ColorName") & "<br />")
Return View()
End Function
End Class
HTML:
<form action="" method="post">
<input type="text" name="ColorName" />
<input type="submit" name="ColorName_SubmitButton" value="Print It Out!" />
</form>
嘗試中的問題是,沒有按需要printed out
顏色名稱。
Reponse.Write
或Request.QueryString
嗎? GET
"invoked"
? Invoked
=生效或執行(來源:《梅里亞姆-韋伯斯特詞典》)
它不是QueryString,而是POST本身。 在C#中,它將是:
Request["ColorName"];
因此,也許只是(不確定,不了解VB):
Request("ColorName")
但是執行此操作的更好方法是實際綁定到MVC模型
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.