/ASP.NET MVC 3
ASP.NET MVC 3
(includes April 2011 Tools Update)
ASP.NET MVC 3 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of ASP.NET and the .NET Framework.
It installs side-by-side with ASP.NET MVC 2, so get started using it today!
Install MVC3 Free
or download the installer here
What's New in ASP.NET MVC 3
Installation and Help
ASP.NET MVC 3 OverviewASP.NET MVC 3 builds on ASP.NET MVC 1 and 2, adding great features that both simplify your code and allow deeper extensibility. This topic provides an overview of many of the new features that are included in this release, organized into the following sections:
Extensible Scaffolding with MvcScaffold integrationThe new Scaffolding system makes it easier to pick up and start using productively if you’re entirely new to the framework, and to automate common development tasks if you’re experienced and already know what you’re doing.
This is supported by new NuGet scaffolding package called MvcScaffolding. The term “Scaffolding” is used by many software technologies to mean “quickly generating a basic outline of your software that you can then edit and customize”. The scaffolding package we’re creating for ASP.NET MVC is greatly beneficial in several scenarios:
Other features in MvcScaffolding include:
The ASP.NET MVC 3 Tools Update includes great Visual Studio support for this scaffolding system, such as:
For more information about Scaffolding in ASP.NET MVC 3, see the following resources:
The New Project dialog includes a checkbox enable HTML 5 versions of project templates. These templates leverage Modernizr 1.7 to provide compatibility support for HTML 5 and CSS 3 in down-level browsers.
The Razor View EngineASP.NET MVC 3 comes with a new view engine named Razor that offers the following benefits:
Some new Razor features include the following:
Razor also includes new HTML helpers, such as the following:
For more information about Razor, see the following resources:
Support for Multiple View EnginesThe Add View dialog box in ASP.NET MVC 3 lets you choose the view engine you want to work with, and the New Project dialog box lets you specify the default view engine for a project. You can choose the Web Forms view engine (ASPX), Razor, or an open-source view engine such as Spark, NHaml, or NDjango.
Controller Improvements Global Action FiltersSometimes you want to perform logic either before an action method runs or after an action method runs. To support this, ASP.NET MVC 2 provided action filters. Action filters are custom attributes that provide a declarative means to add pre-action and post-action behavior to specific controller action methods. However, in some cases you might want to specify pre-action or post-action behavior that applies to all action methods. MVC 3 lets you specify global filters by adding them to the GlobalFilters collection. For more information about global action filters, see the following resources:
MVC 2 controllers support a ViewData property that enables you to pass data to a view template using a late-bound dictionary API. In MVC 3, you can also use somewhat simpler syntax with the ViewBag property to accomplish the same purpose. For example, instead of writing ViewData["Message"]="text", you can write ViewBag.Message="text". You do not need to define any strongly-typed classes to use the ViewBag property. Because it is a dynamic property, you can instead just get or set properties and it will resolve them dynamically at run time. Internally, ViewBag properties are stored as name/value pairs in the ViewData dictionary. (Note: in most pre-release versions of MVC 3, the ViewBag property was named the ViewModel property.)
New "ActionResult" TypesThe following ActionResult types and corresponding helper methods are new or enhanced in MVC 3:
JavaScript and Ajax ImprovementsBy default, Ajax and validation helpers in MVC 3 use an unobtrusive JavaScript approach. Unobtrusive JavaScript avoids injecting inline JavaScript into HTML. This makes your HTML smaller and less cluttered, and makes it easier to swap out or customize JavaScript libraries. Validation helpers in MVC 3 also use the jQueryValidate plugin by default. If you want MVC 2 behavior, you can disable unobtrusive JavaScript using a web.config file setting. For more information about JavaScript and Ajax improvements, see the following resources:
Client-Side Validation Enabled by Default
热门源码