一、视图的作用

视图的职责是向用户提供界面。从ASP.NET MVC3开始,视图数据也可以通过ViewBag属性访问。例如:ViewBag.Message 就等于ViewData["Message"]。

下面来快速浏览一个视图的例子。如下代码片段所示:

 1 @{
 2     Layout = null;
 3 }
 4 
 5 <!DOCTYPE html>
 6 
 7 <html>
 8 <head>
 9     <title>Sample</title>
10 </head>
11 <body>
12     <div>
13         @ViewBag.Message
14     </div>
15 </body>
16 </html>
View Code

相关文章:

猜你喜欢
相关资源
相似解决方案