簡體   English   中英

$ _POST ['color'] for 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顏色名稱。

  1. 問題可能出在Reponse.WriteRequest.QueryString嗎?
  2. 如何得到要處理GET "invoked"

Invoked =生效或執行(來源:《梅里亞姆-韋伯斯特詞典》)

它不是QueryString,而是POST本身。 在C#中,它將是:

Request["ColorName"];

因此,也許只是(不確定,不了解VB):

Request("ColorName") 

但是執行此操作的更好方法是實際綁定到MVC模型

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM