Asp.net MVC 4 的Helloword入门

本文工程代码托管在:https://github.com/Wuchenwcf/MyCode/tree/master/C%23/MVCHelloword

一、环境

本文使用vs2012

二、步骤

1.创建工程

Asp.net MVC 4 的Helloword入门_第1张图片

2.使用Internet应用程序模版


Asp.net MVC 4 的Helloword入门_第2张图片

3.工程建立起来之后就已经有了一个简单的框架了,可以直接运行,跑起来看看

Asp.net MVC 4 的Helloword入门_第3张图片

3.创建Controller

为了写我们的Helloworld,我们来创建一个自己的Controller

Asp.net MVC 4 的Helloword入门_第4张图片

4.修改代码

Asp.net MVC 4 的Helloword入门_第5张图片

5.再跑跑看

Asp.net MVC 4 的Helloword入门_第6张图片

三、总结

这只是一个入门,更多内容可参考微软的官方文档:https://docs.microsoft.com/en-us/aspnet/mvc/mvc4

The first argument to the ActionLink method is the link text to render (for example, Edit Me). The second argument is the name of the action method to invoke. The final argument is an anonymous object that generates the route data (in this case, the ID of 4).

The Html.LabelFor helper displays the name of the field ("Title", "ReleaseDate", "Genre", or "Price"). The Html.EditorFor helper renders an HTML  element. The Html.ValidationMessageFor helper displays any validation messages associated with that property.


你可能感兴趣的:(C#)