ASP.NET MVC - XinxinZhou/ASP.NET-Tutorial GitHub Wiki
Models: Classes that represent the data of the application and that use validation logic to enforce business rules for that data. Views: Template files that your application uses to dynamically generate HTML responses. Controllers: Classes that handle incoming browser requests, retrieve model data, and then specify view templates that return a response to the browser.
http://www.asp.net/mvc/overview/older-versions/getting-started-with-aspnet-mvc4/adding-a-controllere
设计ASP.NET MVC的目的就是来创建网站: 平台设计目标就是相应浏览器请求,返回HTML。 Router: 路由, ASP.NET WEB API, 将URL映射到控制器操作。 模型绑定和验证, 过滤器 Scaffolding 基架 “基架”是指为数据库中的每个表自动生成网页的动态数据元素。 单元测试, 免费版visual studio 可能得独立下载NUnit, MbUnit, xUnit插件。用于测试controller?
https://msdn.microsoft.com/zh-cn/library/ee377606(v=vs.100).aspx
ASP.NET MVC 依赖 conventions. Convention over configuration is a software design paradigm which seeks to decrease the number of decisions that developers need to make, gaining simplicity, and not necessarily losing flexibility. The phrase essentially means a developer only needs to specify unconventional aspects of the application. 即只需要配置与应用中不符约定的部分。
Controllers. 响应浏览器的HTTP请求,返回信息到浏览器。 定义: Controllers within the MVC pattern are responsible for responding to user input, often making changes to the model in response to user input. Views input data -> controller -> output data -> Views rendering HTML
Controller { Index() // 决定网站主页的访问响应内容。 Browse(int id) // controller action, 参数通过HTTP GET 从URL获取. } 比如访问 Store/Browse?id=?1, action就可以获取该参数。
Views: [ViewBag, ViewData[""] ]
dynamic values cannot be passed in as parameters to extension methods. The C# compiler must know the real type of every parameter at compile time in order for it to choose the correct extension method.
code will always fail: @Html.TextBox("name", ViewBag.Name). To work around this, either use ViewData["Name"] or cast the value to a specifi c type: (string) ViewBag.Name.
IntelliSense?
Controller 与 view 结合,通过 在controller action里处理数据,通过viewbag或者viewdata传送
MVCMUSIC