<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>裁纸刀下 &#187; 动手实验</title>
	<atom:link href="http://ofcss.com/tags/lab/feed" rel="self" type="application/rss+xml" />
	<link>http://ofcss.com</link>
	<description>独立 自由 诚信 宽容 责任 平常心</description>
	<lastBuildDate>Thu, 19 Jan 2012 14:24:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</title>
		<link>http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html</link>
		<comments>http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html#comments</comments>
		<pubDate>Mon, 13 Apr 2009 17:41:50 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[所谓技术]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[动手实验]]></category>
		<category><![CDATA[翻译]]></category>

		<guid isPermaLink="false">http://wukangrui.net/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html</guid>
		<description><![CDATA[<p>在这次的练习中，你将学习如何开发一个 ASP.NET 应用，整个练习过程包括创建控制器、视图和模型。 通过这次练习，要创建一个分页显示用户列表的 ASP.NET MVC应用。具有显示用户资料，以及创建、修改、删除用户地址的功能。该应用共有三个控制器：用户控制器处理用户信息列表和显示用户信息；地址控制器负责用户地址的创建、编辑和删除；主页控制器负责显示站点的欢迎页面。 提示：为了确保每个步骤都正常运行，最好在每个任务结束的时候都编译整个解决方案。 任务1 &#8211; 创建实体数据模型 在本任务中你要用 实体数据模型（Entity Data Model）创建可编程实体类到数据存储结构（通常是SQL Server数据库或者其他数据库）的映射。Entity Data Model (EDM) 是在 实体框架 (Entity Framework）中专门设计来作为程序中的数据定义的。 点击 开始 &#124; 所有程序 &#124; Microsoft Visual Studio 2008 &#124; Microsoft Visual Studio 2008 启动 VS 2008。 打开 &#8230; <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p>在这次的练习中，你将学习如何开发一个 ASP.NET 应用，整个练习过程包括创建控制器、视图和模型。</p>
<p>通过这次练习，要创建一个分页显示用户列表的 ASP.NET MVC应用。具有显示用户资料，以及创建、修改、删除用户地址的功能。该应用共有三个控制器：用户控制器处理用户信息列表和显示用户信息；地址控制器负责用户地址的创建、编辑和删除；主页控制器负责显示站点的欢迎页面。</p>
<p>提示：为了确保每个步骤都正常运行，最好在每个任务结束的时候都编译整个解决方案。</p>
<p> <span id="more-474"></span>
<p><b>任务1 - 创建实体数据模型</b></p>
<p>在本任务中你要用 <strong>实体数据模型</strong>（<strong>Entity Data Model</strong>）创建可编程实体类到数据存储结构（通常是SQL Server数据库或者其他数据库）的映射。<strong>Entity Data Model</strong> (EDM) 是在 实体框架 (Entity Framework）中专门设计来作为程序中的数据定义的。</p>
<ol>
<li>点击 <strong>开始 | 所有程序 | Microsoft Visual Studio 2008 | Microsoft Visual Studio 2008</strong> 启动 VS 2008。</li>
<li> 打开 <strong>AspNetMvcEx02-DevelopingMvcAppbegin</strong> 目录下的解决方案文件 <strong>MvcSampleApp.sln</strong>。</li>
<li>在 <strong>解决方案浏览器</strong> 中， 打开 <strong>Views</strong> 目录下的 <strong>Shared</strong> 目录。步骤：点击目录名字前面的加号图标，选择 <strong>Site.Master</strong> 文件， 右键点击它并选择 <strong>删除 </strong>。</li>
<li>导入提供的 Site.Master。 步骤：右键点击 <strong>Shared</strong> 文件夹， 指向 <strong>添加</strong> 然后选择 <strong>现有项</strong>。在 <strong>添加现有项</strong> 对话框中，转到 <strong>AspNetMvcAssetsShared</strong> 目录，然后选中该目录下的所有文件（实际就只有一个 Site.Master 文件），点 <strong>添加</strong>。&#160;
<p>提示：与传统的 ASP.NET Web 页面一样， ASP.NET 页面视图 (.aspx 文件)可以使用母版页来为站点的通用部分提供统一的样式。</p>
</li>
<li>
<p>创建 <strong>AdventureWorks</strong> 实体数据模型。步骤：在 解决方案浏览器 中， 在 <strong>MvcSampleApp</strong> 项目中右键点击 <strong>Models</strong> 文件夹， 指向 <strong>添加</strong>， 然后点击 <strong>新建项</strong>。</p>
</li>
<li>在 <strong>新建项</strong> 对话框里选择 <strong>ADO.NET Entity Data Model</strong>。将要创建的项命名为 <strong>AdventureWorks.edmx</strong>，然后点 <strong>添加</strong>。&#160;
<p><a href="http://file.wukangrui.com/attachments/2009/04/image7.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb7.png" width="644" height="437" /></a>        <br /><em><strong>图一</strong> 添加 ADO.NET Entity Data Model</em></p>
</li>
<li>在 <strong>实体模型数据向导</strong> 打开后， 选择 <strong>从数据库生成</strong> 然后点击 <strong>下一步</strong>。</li>
<li>点击 <strong>新建连接</strong> 定义数据库连接。 </li>
<li>In the <b>Choose Data Source</b> dialog, select <b>Microsoft SQL Server</b> as <b>Data Source</b> and click <b>Continue</b>. 在 <strong>选择数据库</strong> 对话框中，选择<strong> Microsoft SQL Server</strong> 作为数据源，然后点 <strong>继续</strong>。（这一步在大部分情况下默认不出现）</li>
<li>In the <b>Connection Properties</b> dialog window, enter <b>AspNetMvcLabs</b> as <b>Server Name</b>, then select <b>AdventureWorksLT</b> database and click <b>OK</b>.在 <strong>连接属性</strong> 对话框里，输入你的 <strong>本地 SQL Server 安装实例 </strong>名称（例如“.”或者“.SQLEXPRESS”），然后在下方选择 <strong>AdventureWorksLT</strong> 数据库 （没有安装 SQL Server 2005 示例数据库的可以从网上下载安装），然后点击 <strong>OK</strong>。
<p>Note:<b>AspNetMvcLabs</b> is the default alias for the database server installed when the <b>SetupEx.cmd</b> script was run at the beginning of this lab.</p>
<p><a href="http://file.wukangrui.com/attachments/2009/04/image8.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb8.png" width="455" height="733" /></a>&#160; <br /><em><b>图二 </b>定义数据连接</em></p>
</li>
<li>回到 <strong>实体数据模型向导</strong>， 点击 <strong>下一步</strong>。</li>
<li>在 <strong>选择数据库对象</strong> 这一步，只需要选择以下三个表：&#160;
<ul>
<li><b>Address (SalesLT)Address </b></li>
<li><b>Customer (SalesLT)</b></li>
<li><b>CustomerAddress (SalesLT)</b></li>
</ul>
</li>
<li>保持 <strong>模型命名空间</strong> 这一项为默认值，点击 <strong>完成</strong>。&#160;
<p><a href="http://file.wukangrui.com/attachments/2009/04/image9.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb9.png" width="484" height="484" /></a>&#160; <br /><strong>图三 </strong><i>选择要包含在模型中的数据库对象</i></p>
</li>
<li>
<p>创建数据容器类 AdventureWorksRepository，这个容器类向其它类暴露数据访问方法，通过这些方法从底层数据模型获取数据实体。在 MvcSampleApp 项目中右击 Models 目录，指向 添加 然后点击 现有项。转到 AspNetMvcAssets 目录， 选择 AdventureWorksRepository.cs 文件，然后点击 添加。       <br />提示：更多详细信息，参见 <a href="http://msdn2.microsoft.com/zh-cn/library/bb387122.aspx" target="_blank">实体数据模型</a> 。</p>
</li>
</ol>
<p>（未完待续）</p>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html" title="[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html" title="[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述">[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述</a></li><li>2009-07-08 -- <a href="http://ofcss.com/2009/07/08/asp-net-mvc-best-practices-part-4.html" title="ASP.NET MVC 最佳实践（四）">ASP.NET MVC 最佳实践（四）</a></li><li>2009-07-07 -- <a href="http://ofcss.com/2009/07/07/asp-net-mvc-best-practices-part-3.html" title="ASP.NET MVC 最佳实践（三）">ASP.NET MVC 最佳实践（三）</a></li><li>2009-07-01 -- <a href="http://ofcss.com/2009/07/01/asp-net-mvc-best-practices-part-2.html" title="ASP.NET MVC 最佳实践（二）">ASP.NET MVC 最佳实践（二）</a></li><li>2009-06-28 -- <a href="http://ofcss.com/2009/06/28/asp-net-mvc-best-practices-part-1.html" title="ASP.NET MVC 最佳实践（一）">ASP.NET MVC 最佳实践（一）</a></li><li>2009-04-30 -- <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html" title="VS2008 中 JS IntelliSense出错的解决">VS2008 中 JS IntelliSense出错的解决</a></li><li>2011-03-14 -- <a href="http://ofcss.com/2011/03/14/browser-rendering-optimizer-translation-extra.html" title="对《优化浏览器渲染》的补充【译】">对《优化浏览器渲染》的补充【译】</a></li><li>2011-03-10 -- <a href="http://ofcss.com/2011/03/10/css-border-tricks-with-collapsed-boxes-translation.html" title="CSS边框实现&ldquo;无图化&rdquo;设计【译】">CSS边框实现&ldquo;无图化&rdquo;设计【译】</a></li><li>2010-10-31 -- <a href="http://ofcss.com/2010/10/31/prevent-a-float-drop-in-ie6-translation.html" title="CSS技巧:如何避免IE6中的&quot;浮动下坠&quot;【译】">CSS技巧:如何避免IE6中的&quot;浮动下坠&quot;【译】</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用</title>
		<link>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html</link>
		<comments>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html#comments</comments>
		<pubDate>Thu, 09 Apr 2009 15:08:09 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[所谓技术]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[动手实验]]></category>
		<category><![CDATA[翻译]]></category>

		<guid isPermaLink="false">http://wukangrui.net/2009/04/09/aspnetmvc-hands-on-labs-create-application.html</guid>
		<description><![CDATA[<p>在这个练习中你将学习如何在 Visual Studio 中创建一个 ASP.NET MVC 应用。并初步了解默认项目结构和一些开发约定。 ASP.NET MVC 框架分为 Model， View 和 Controller 三个部分。模型组件（Model）一般用于维护数据库中的持久数据层的状态。视图组件（View）由控制器挑选并渲染到适当的用户界面。默认状态下， ASP.NET MVC 框架用ASP.NET已有的 ASP.NET 页面（.aspx）、 母版页（.master）以及用户控件（.ascx）等类型来作为浏览器呈现。控制器组件（Controller）组件将用户请求定位到适当的控制器（Controller）行为（Action）和方法（Method），从请求中获取用于行为方法运行的参数值， 并处理行为和方法执行中可能产生的错误。 然后控制器用该请求对应的视图进行渲染。 默认状况下，每个组件存放在 MVC WEB 应用工程的一个独立目录下。 任务1 &#8211; 创建一个 ASP.NET MVC Web 应用工程 在这个任务中你将通过Visual Studio的MVC模板创建和配置一个空的 ASP.NET MVC 应用工程。 打开 &#8230; <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p>在这个练习中你将学习如何在 Visual Studio 中创建一个 ASP.NET MVC 应用。并初步了解默认项目结构和一些开发约定。</p>
<p>ASP.NET MVC 框架分为 Model， View 和 Controller 三个部分。模型组件（Model）一般用于维护数据库中的持久数据层的状态。视图组件（View）由控制器挑选并渲染到适当的用户界面。默认状态下， ASP.NET MVC 框架用ASP.NET已有的 ASP.NET 页面（.aspx）、 母版页（.master）以及用户控件（.ascx）等类型来作为浏览器呈现。控制器组件（Controller）组件将用户请求定位到适当的控制器（Controller）行为（Action）和方法（Method），从请求中获取用于行为方法运行的参数值， 并处理行为和方法执行中可能产生的错误。 然后控制器用该请求对应的视图进行渲染。 默认状况下，每个组件存放在 MVC WEB 应用工程的一个独立目录下。</p>
<p><span id="more-444"></span></p>
<p><strong>任务1 - 创建一个 ASP.NET MVC Web 应用工程</strong></p>
<p>在这个任务中你将通过Visual Studio的MVC模板创建和配置一个空的 ASP.NET MVC 应用工程。</p>
<ol>
<li>打开 Microsoft Visual Studio 2008：依次点击 <strong>开始</strong>|<strong>所有程序</strong>|<strong>Microsoft Visual Studio 2008</strong>|<strong>Microsoft Visual Studio 2008</strong>.</li>
<li>点击 <strong>文件</strong> 菜单， 指向 <strong>新建</strong>， 然后点击 <strong>项目</strong>。</li>
<li>在 <strong>新建项目</strong> 对话框中，确保右上角选中的版本为 <strong>.NET Framework 3.5</strong>，在 <strong>项目类型</strong> 下选择 <strong>Visual C#</strong>，然后在 <strong>Visual Studio 已安装的模板</strong> 中选择 <strong>ASP.NET MVC Web Application</strong> 类型。你可以设置项目位置为 <strong>你的路径AspNetMvcEx01-CreatingMvcAppbegin </strong>作为项目目录。</li>
<li>修改 <strong>名称</strong> 为 <strong>MvcSampleApp</strong> 然后点击 确定 。 <a href="http://file.wukangrui.com/attachments/2009/04/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb.png" border="0" alt="image" width="605" height="484" /> </a><em>图一：创建新项目对话框<br />
</em>在点击 确定 按钮之后，Visual Studio 会问你是否同时创建测试项目（would you like to create a test project）。选择 <strong>Yes</strong>， 输入 <strong>MvcSampleApp.Test</strong> 作为<strong>项目名称</strong>（<strong>Name</strong> of the Project）， 然后点击 <strong>确定</strong>（<strong>OK</strong>）。注：我安装的是Visual Studio 2008 SP1 简体中文版 + ASP.NET MVC 1.0，在我的系统上，创建测试项目的对话框为英文，因此这里加上英文对照。<br />
提示：当你创建一个新的MVC Web应用时， Visual Studio 会为你提供同时创建两个项目的选择，第一个项目是Web项目用来实现你的应用，第二个项目是一个测试项目，你可以在其中为你的MVC组件编写单元测试。<br />
<a href="http://file.wukangrui.com/attachments/2009/04/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb2.png" border="0" alt="image" width="552" height="367" /></a><br />
<em>图二：创建 MVC 单元测试项目<br />
</em>提示：测试项目对话框中的 测试框架（Test Framework） 下拉列表现在只有一个 Visual Studio Unit Test，这个列表是可扩展的，在你的机器上安装了其他测试框架的时候，它将会包含其他的测试框架供你选择。由此你可以容易地用你喜欢的单元测试框架来为你的 ASP.NET MVC 应用编写单元测试。</li>
<li>在Visual Studio 中配置站点使用端口 50000。这一步是为了和本动手实验中的后续联系保持一致所必须的。
<ol type="a">
<li>在 <strong>解决方案浏览器</strong> 中，右击 <strong>MvcSampleApp</strong> 项目，并在上下文菜单中选择 <strong>属性</strong> 。</li>
<li>在 <strong>属性</strong> 页中，打开 <strong>Web</strong> 标签。</li>
<li>In the <strong>Servers</strong> section select <strong>Specific Port</strong>. 在 <strong>服务器</strong> 设置项下面，选择 <strong>使用Visual Studio开发服务器</strong>，并选中 <strong>特定端口</strong> 。</li>
<li>设置端口号为 <strong>50000</strong> 。</li>
<li>按下 <strong>Ctr + S</strong> 保存所做的改动。</li>
</ol>
<p><a href="http://file.wukangrui.com/attachments/2009/04/image3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://file.wukangrui.com/attachments/2009/04/image-thumb3.png" border="0" alt="image" width="635" height="480" /></a><br />
<em>图三：配置本地测试属性</em></li>
</ol>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2009-04-13 -- <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html" title="[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html" title="[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述">[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述</a></li><li>2009-07-08 -- <a href="http://ofcss.com/2009/07/08/asp-net-mvc-best-practices-part-4.html" title="ASP.NET MVC 最佳实践（四）">ASP.NET MVC 最佳实践（四）</a></li><li>2009-07-07 -- <a href="http://ofcss.com/2009/07/07/asp-net-mvc-best-practices-part-3.html" title="ASP.NET MVC 最佳实践（三）">ASP.NET MVC 最佳实践（三）</a></li><li>2009-07-01 -- <a href="http://ofcss.com/2009/07/01/asp-net-mvc-best-practices-part-2.html" title="ASP.NET MVC 最佳实践（二）">ASP.NET MVC 最佳实践（二）</a></li><li>2009-06-28 -- <a href="http://ofcss.com/2009/06/28/asp-net-mvc-best-practices-part-1.html" title="ASP.NET MVC 最佳实践（一）">ASP.NET MVC 最佳实践（一）</a></li><li>2011-03-14 -- <a href="http://ofcss.com/2011/03/14/browser-rendering-optimizer-translation-extra.html" title="对《优化浏览器渲染》的补充【译】">对《优化浏览器渲染》的补充【译】</a></li><li>2009-06-22 -- <a href="http://ofcss.com/2009/06/22/whatever-hover-pseudo-class-without-javascript.html" title="Whatever:hover &#8211; 无需javascript让IE支持丰富伪类">Whatever:hover &#8211; 无需javascript让IE支持丰富伪类</a></li><li>2009-04-30 -- <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html" title="VS2008 中 JS IntelliSense出错的解决">VS2008 中 JS IntelliSense出错的解决</a></li><li>2011-03-10 -- <a href="http://ofcss.com/2011/03/10/css-border-tricks-with-collapsed-boxes-translation.html" title="CSS边框实现&ldquo;无图化&rdquo;设计【译】">CSS边框实现&ldquo;无图化&rdquo;设计【译】</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[翻译]ASP.NET MVC动手系列1-1：ASP.NET MVC概述</title>
		<link>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html</link>
		<comments>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html#comments</comments>
		<pubDate>Thu, 09 Apr 2009 14:41:35 +0000</pubDate>
		<dc:creator>小李刀刀</dc:creator>
				<category><![CDATA[所谓技术]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[动手实验]]></category>
		<category><![CDATA[翻译]]></category>

		<guid isPermaLink="false">http://wukangrui.net/2009/04/09/aspnetmvc-hands-on-labs-introduction.html</guid>
		<description><![CDATA[<p>MVC(Model View Controller) 架构模式通常分为三个主要部分： 模型（Models）：模型对象一般是在应用中实现逻辑域的部分。通常情况下，模型对象用于在数据库中取得和存储模型状态。 视图（Views）：视图是应用中显示用户界面（UI）的组件。典型状况下，用户界面是根据模型数据创建。比如一个产品表的编辑视图中可能包括基于当前产品对象状态的文本框、下拉列表以及单选、复选框等。 控制器（Controllers）：控制器是处理用户交互，操作对应模型、最后选择相应视图来渲染用户界面的组件。在一个MVC架构的应用中，视图只用于显示信息；控制器对用户的输入和交互行为进行处理和响应。 MVC模式可以帮助你将应用拆分的不同方面拆分以形成多层结构（输入逻辑、商业逻辑和用户界面逻辑等），并为这些不同的层提供宽松的耦合关系。这样你就能在开发过程中一次只将精力集中于实现其中的一个方面。除了在处理复杂事务的优势外，调试基于MVC模式的应用也比调试传统ASP.NET WEB应用程序更容易， 因此MVC模式鼓励使用测试驱动开发（TDD: Test-driven development）来创建应用程序。 ASP.NET MVC 框架为ASP.NET Web Forms开发人员提供了创建基于MVC的WEB应用的选择。ASP.NET MVC 框架是一个轻量级的、高可测试性的框架，它与基于Web Forms的应用程序一样，结合了现有的ASP.NET特性，例如母版页和基于用户（Membership-based）的认证等。 除此之外，MVC应用程序三个主要组件之间的宽耦合更方便进行多人并行开发。例如，一个开发人员开发试图，另一个开发人员开发逻辑控制器，与此同时还有一个开发人员在模型层进行商业逻辑开发。 目标 在这个动手实验室系列中，你将学习到： 认识和了解 ASP.NET MVC 框架； 创建一个 ASP.NET MVC 应用程序； 在创建 ASP.NET MVC 应用程序的过程中执行测试。 &#160; 系统需求 为了完成此实验，你必须具备以下的系统配置环境： Microsoft Visual &#8230; <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html">Continue reading <span class="meta-nav">&#8594;</span></a></p>
]]></description>
			<content:encoded><![CDATA[<p>MVC(Model View Controller) 架构模式通常分为三个主要部分：</p>
<ul>
<li>模型（Models）：模型对象一般是在应用中实现逻辑域的部分。通常情况下，模型对象用于在数据库中取得和存储模型状态。</li>
<li>视图（Views）：视图是应用中显示用户界面（UI）的组件。典型状况下，用户界面是根据模型数据创建。比如一个产品表的编辑视图中可能包括基于当前产品对象状态的文本框、下拉列表以及单选、复选框等。</li>
<li>控制器（Controllers）：控制器是处理用户交互，操作对应模型、最后选择相应视图来渲染用户界面的组件。在一个MVC架构的应用中，视图只用于显示信息；控制器对用户的输入和交互行为进行处理和响应。</li>
</ul>
<p> <span id="more-442"></span>
<p>MVC模式可以帮助你将应用拆分的不同方面拆分以形成多层结构（输入逻辑、商业逻辑和用户界面逻辑等），并为这些不同的层提供宽松的耦合关系。这样你就能在开发过程中一次只将精力集中于实现其中的一个方面。除了在处理复杂事务的优势外，调试基于MVC模式的应用也比调试传统ASP.NET WEB应用程序更容易， 因此MVC模式鼓励使用测试驱动开发（TDD: Test-driven development）来创建应用程序。</p>
<p><strong>ASP.NET MVC</strong> 框架为ASP.NET Web Forms开发人员提供了创建基于MVC的WEB应用的选择。<strong>ASP.NET MVC</strong> 框架是一个轻量级的、高可测试性的框架，它与基于Web Forms的应用程序一样，结合了现有的ASP.NET特性，例如母版页和基于用户（Membership-based）的认证等。</p>
<p>除此之外，MVC应用程序三个主要组件之间的宽耦合更方便进行多人并行开发。例如，一个开发人员开发试图，另一个开发人员开发逻辑控制器，与此同时还有一个开发人员在模型层进行商业逻辑开发。</p>
<h3>目标</h3>
<p>在这个动手实验室系列中，你将学习到：</p>
<ul>
<li>认识和了解 ASP.NET MVC 框架；</li>
<li>创建一个 ASP.NET MVC 应用程序；</li>
<li>在创建 ASP.NET MVC 应用程序的过程中执行测试。</li>
</ul>
<p>&#160;</p>
<p> <a href="#" name="_Toc168302999"></a><a href="#" name="_Toc157870738"></a><br />
<h3>系统需求</h3>
<p>为了完成此实验，你必须具备以下的系统配置环境：</p>
<ul>
<li>Microsoft Visual Studio 2008 SP1</li>
<li>Microsoft ASP.NET MVC 1.0 </li>
<li>Microsoft SQL 2005 or Microsoft SQL 2008 (体验版或更高版本) </li>
<li>Adventure Works 示例数据库
<ul>
<li>Microsoft SQL 2005 下使用: <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=4004" target="_blank">AdventureWorksLT.msi</a>
<p><b>备注：</b> 该 msi 安装程序只是将示例数据库文件拷贝到你的文件系统中；你还需要手动在SQL SERVER服务器中附加该数据库。更多信息，请参考 <a href="http://technet.microsoft.com/zh-cn/library/ms190209.aspx" target="_blank">如何：在SQL Server Management Studio 中附加数据库</a>.            <br /><i>Vista 用户请注意：</i> 确认将数据库文件安装到 “C:Program Files”以外的目录， 因为该文件夹具有额外的权限设置，可能会由于文件的只读属性造成你无法在工程文件中进行保存。</p>
</li>
<li>Microsoft SQL 2008 下使用: <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=18407">AdventureWorks 2008 sample databases</a>
<p><b>备注：</b> 该 msi 安装程序只是将示例数据库拷贝到你的文件系统中；不过，你只需要用到 <strong>AdventureWorksLT</strong> 数据库。</p>
<p>&#160;</p>
</li>
</ul>
</li>
</ul>
<h3>安装</h3>
<p>本实验所需的所有必备组件可以用依赖性检测工具来检验。要确定所有项目都已正确配置，请执行以下步骤：</p>
<p>备注：要执行以下安装步骤，你需要在以管理员身份运行的命令提示窗口（cmd.exe）中运行所有脚本。</p>
<ol>
<li>如果以前从没有进行过依赖性检测，请运行依赖性检测工具。要进行检测，运行 CheckDepenencies.cmd 脚本，该脚本位于 <strong>%TrainingKitInstallation%LabsaspNetMvcSetup</strong> 目录。根据向导提示扫描并安装任何缺少的组件（安装后，如果需要可以重新扫描）。
<p>提示：为了方便起见，在这个实验中你将用到的绝大部分代码会安装在Visual Studio 的 代码片段（code snippets）中。CheckDependencies.cmd 结束时会自动加载 Visual Studio 安装管理器来安装代码片段。</p>
</li>
</ol>
<h3>练习</h3>
<p>这个动手实验中包含以下练习：</p>
<ol>
<li>创建 ASP.NET MVC 应用程序 </li>
<li>开发和完善 ASP.NET MVC 应用程序 </li>
<li>测试 ASP.NET MVC 应用程序</li>
</ol>
<p>完成整个实验预计需要时间: <b>90分钟。</b></p>
<p>补充说明:</p>
<p><a href="#" name="_Toc166647553"></a><a href="#" name="_Toc172462715"></a><a href="#" name="_Toc182141329"></a>每个练习中都包含一个起始解决方案，起始解决方案中缺少的代码将在练习工程中完成。因此如果你直接运行起始解决方案，将不能正常执行。    <br />在每个练习中你还可以找到一个 End 目录，其中包括了在整个练习结束时你应该得到的解决方案。在练习过程中如果你需要额外的帮助，可以参考该解决方案。</p>
<p>（文本翻译自 ASP.NET MVC Training Kit，下载地址：<a title="http://www.microsoft.com/downloads/details.aspx?FamilyID=1E0BE0B2-910A-4676-9F3A-41E4D9C0FC08&amp;displaylang=en" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=1E0BE0B2-910A-4676-9F3A-41E4D9C0FC08&amp;displaylang=en">http://www.microsoft.com/downloads/details.aspx?FamilyID=1E0BE0B2-910A-4676-9F3A-41E4D9C0FC08&amp;displaylang=en</a>）</p>
<h3  class="related_post_title">相关日志</h3><ul class="related_post"><li>2009-04-13 -- <a href="http://ofcss.com/2009/04/13/aspnetmvc-hands-on-labs-develop-application.html" title="[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-3：开发ASP.NET MVC应用</a></li><li>2009-04-09 -- <a href="http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-create-application.html" title="[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用">[翻译]ASP.NET MVC动手实验1-2：创建ASP.NET MVC应用</a></li><li>2009-07-08 -- <a href="http://ofcss.com/2009/07/08/asp-net-mvc-best-practices-part-4.html" title="ASP.NET MVC 最佳实践（四）">ASP.NET MVC 最佳实践（四）</a></li><li>2009-07-07 -- <a href="http://ofcss.com/2009/07/07/asp-net-mvc-best-practices-part-3.html" title="ASP.NET MVC 最佳实践（三）">ASP.NET MVC 最佳实践（三）</a></li><li>2009-07-01 -- <a href="http://ofcss.com/2009/07/01/asp-net-mvc-best-practices-part-2.html" title="ASP.NET MVC 最佳实践（二）">ASP.NET MVC 最佳实践（二）</a></li><li>2009-06-28 -- <a href="http://ofcss.com/2009/06/28/asp-net-mvc-best-practices-part-1.html" title="ASP.NET MVC 最佳实践（一）">ASP.NET MVC 最佳实践（一）</a></li><li>2009-04-30 -- <a href="http://ofcss.com/2009/04/30/solution-for-js-intellisense-error.html" title="VS2008 中 JS IntelliSense出错的解决">VS2008 中 JS IntelliSense出错的解决</a></li><li>2011-03-14 -- <a href="http://ofcss.com/2011/03/14/browser-rendering-optimizer-translation-extra.html" title="对《优化浏览器渲染》的补充【译】">对《优化浏览器渲染》的补充【译】</a></li><li>2011-03-10 -- <a href="http://ofcss.com/2011/03/10/css-border-tricks-with-collapsed-boxes-translation.html" title="CSS边框实现&ldquo;无图化&rdquo;设计【译】">CSS边框实现&ldquo;无图化&rdquo;设计【译】</a></li><li>2010-10-31 -- <a href="http://ofcss.com/2010/10/31/prevent-a-float-drop-in-ie6-translation.html" title="CSS技巧:如何避免IE6中的&quot;浮动下坠&quot;【译】">CSS技巧:如何避免IE6中的&quot;浮动下坠&quot;【译】</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://ofcss.com/2009/04/09/aspnetmvc-hands-on-labs-introduction.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

