Get Start

Contents

为什么推出MVCModel-View-Controller)?... 1

开发前的准备... 1

第一支Asp.Net Mvc 网站开发(小试牛刀)... 1

 

 

为什么推出MVCModel-View-Controller)?

相信我们都很熟悉微软.NET Web Forms的应用开发形式, 为什么又出现了Asp.Net Mvc这种网络应用的开发架构呢? 原因就在于传统的Web Form开发形式有它一定的局限,比如单元测试、超大型应用开发的分布管理等。 Asp.Net Mvc  恰恰在这些方面有其独到之处,如目标需求的分离、测试驱动的开发形式、对纯HTMLJavaScripts良好控制及URL的呼应。但Asp.Net Mvc 并不是对WebForm的替代,仅仅是 给了我们更多的选择,需要我们根据具体项目的需求去决定哪种形式更贴近需要。

开发前的准备

Visual Studio 2008 中很简单,只需下载Asp.Net Mvc framework 进行安装即可。目前的版本是Asp.net Mvc Beta。另外,需要安装Microsoft Visual Studio 2008 service pack 1。在Visual  Studio 2005 中,还必须安装.Net3.5 framework 因为Mvc  架构是建立在.Net3.5 framework 之上的。以上顺利安装后,重新启动Visual Studio 2008 在新建项目中就可以看到 Asp.Net Mvc Web Application 的模板,如下图(图 0-1):

 

好了,现在可以开始创建Asp.Net Mvc project啦!

 

第一支Asp.Net Mvc 网站开发(小试牛刀)

建立一支初试的Mvc网站非常简单,这要归功于微软提供的强大的Visual Studio 2008 工具。

如建立其他网站一样, 启动Visual Studio 2008,逐一点击 [文件][新建][项目] 在项目模板中选择 [Asp.Net Mvc项目](如图 0-1),然后再项目名称的文本框键入“myFirstMvcApp”,选择要保存的文件夹位置,点击 [OK] 到下一步。在弹出的建立单元测试项目窗口点选“Yes”,键入测试项目的名称或使用缺省值, 下面的测试架构的下拉菜单中,可以选择已经安装在Visual Studio 2008的测试架构,这里用缺省的“Visual Studio Unit Test”。点击“OK”完成项目创建。在“Solution Explorer”中可以看到自动创建的项目(图 0-3)。

 

运行该项目,第一次运行会提示是否修改Web. Config的文件,点击“Yes”即可。 现在第一支Mvc架构的页面便呈现出来(图 0-4)。

 

到这里吧, 休息,休息!

 

Contents

v     Why Mvc (Model-View-Controller)?  1

v     How to get start?  1

v     My first Asp.Net Mvc project  2

 

 

v Why Mvc (Model-View-Controller)?

 

As we are already familiar with .net web forms application, and it works very well,  so why would we still need to move on to Asp.Net Mvc?  The reason is simple, web forms style application does not  provide sufficient developing needs, for example, frustrating unit test, difficulty on large-scale web application developing handling, etc. Asp.net Mvc gives web application developing team an edge on clear separation of concerns, testability-support for Test-Driven Development, fine-grained control over HTML and JavaScript (ref: http://www.asp.net/mvc/  2008/12/04), and intuitive URLs. However, Asp.net Mvc is not a replacement of Asp.net Web forms but an alternative.

v How to get start?

 

With Visual Studio 2008, it is pretty easy. First of all, download Asp.Net Mvc framework.  By the time of writing this, the latest release is Asp.net Mvc Beta.  Microsoft Visual Studio 2008 service pack 1 may also required. If you work on Visual Studio 2005, the .Net 3.5 framework has to be installed, because Asp.net Mvc is built on the top of existing .Net 3.5 framework. 

As long as everything figured out, start Visual Studio 2008, you should have ASP.NET MVC Web Application in the project template box as the figure (Figure 0-1) shown below:

 

(Figure 0-1)

Well, now you are ready to develop your first Asp.Net Mvc project. How exciting!

v My first Asp.Net Mvc project

 

Thanks for Microsoft great work, make the developing work such easy and enjoyable. To build a Asp.Net Mvc application is very straight forward.

Start Visual Studio 2008, click menu ‘File’-‘New ’-‘Project’,  highlight the ASP.NET MVC Web Application in the project templates area just like figure 0-1 , type “myFirstMvcApp” in name textbox, specify the location, click ‘ok’ button. Now a promote of ‘Create Unit Test Project’ form will be seen, if you have NUnit  or other testing application installed with Visual Studio 2008, well, you can just click on the dropdown list to select your favorate. For now , I use its default Visual Studio Unit Test as you can see in the following figure (Figure 0-2).

 

(Figure 0-2)

Click ‘OK’ button to finish. The project is built and displayed in ‘Solution Explorer’ (Figure 0-3 ).

 

(Figure 0-3)

Run the project, you should be asked wether or not to modify web.config with a form, click ‘Ok’. Here we go, the most famous Index page comes (Figure 0-4) .

 

(Figure 0-4)

Stop here, have fun with the firs ASP.NET Mvc Web application!

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值