使用的工具: VB.NET 2012、MVC 4、Visual Studio 2012
控制器:SubmitFormController.vb
Namespace MvcApplication19
Public Class UserNamePrintOutSubmitClassController
Inherits System.Web.Mvc.Controller
' This method will handle GET
Function Technology() As ActionResult
Return View("Technology")
End Function
' This method will handle POST
<HttpPost>
Function UserNamePrintOut() As ActionResult
' Do something
Response.Write("Hello " & Request.QueryString("UserName") & "<br />")
Return View()
End Function
End Class
End Namespace
视图:Technology.vbhtml
网址: http://localhost/Home/Technology/
<form action="" method="post">
<input type="text" name="UserName" />
<input type="submit" name="UserName_submit" value="Print It Out!" />
</form>
问题
在这个例子中我没有模型。目的是UserName
使用提交按钮提交并将其打印在屏幕上,on page load
. 这意味着,UserName
应该传递给action method
并打印在屏幕上。
我没有错误消息,但是,UserName
屏幕上没有打印出来,也许有人可以看看上面的代码。
我一直在尝试使用通常在 C# 中的教程。我的背景是 PHP,我仍然倾向于从“echo”的角度来思考——然而,我已经习惯了 MVC 4。