目的是通过按下按钮来访问控制器中的模块。
因此,HelloWorld 消息确实会打印在屏幕上。
目录结构
- 模型/HelloWorldController.vb
- 意见/首页/FrontPage.vbhtml
- 意见/_ViewStart.vbhtml
- 视图/共享/_Layout.vbhtml
示例代码
FrontPage.vhtml
<h1>Cause the HelloWorld Line...</h1>
<form name="hello_world_button" action="" method="post">
<button type="button" name="button">Press it!</button>
</form>
HelloWorldController.vb
Module HelloWorld
' Every console application starts with Main
Sub Main()
System.Console.WriteLine("Hello world!")
End Sub
End Module
使用的工具
Visual Studio 2012、Visual Basic、MVC 4
进一步的附录
对于那些想知道的人,这里展示了使用 PHP 的预期 HelloWorld 应用程序 - (PHP 一直是我在编程方面的背景)
<body>
<form action="" method="POST">
<button name="button">Press It!</button>
</form>
<?php
$button = $_POST['button'];
if(isset($button)) {
echo "Hello World Message!";
}
?>
</body>
这是一个可以查看的示例:单击此处
URL 路由
我目前还专注于 VB.NET 的“路由”和“http”协议系统。
我尝试了以下方法:
<h1>Cause the HelloWorld Line...</h1>
<form name="hello_world_button" action="@Url.Action("HelloWorld", "~/~/Models/HelloWorldController.vb")" method="post">
<button type="button" name="button">Press it!</button>
</form>
HTMLaction
属性包含url.action
带有模块名称HelloWorld
和控制器文件路径的命令。
但是,当按下按钮时,消息不会打印在屏幕上。
有没有办法检查是否routing
正确?