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 Mvc. Scaffold integration. The new Scaffolding system makes it easier to pick up and start using productively if you. The scaffolding package we. It saves you from the trauma of looking at a blank page and having no idea where to start! If you know ASP. NET MVC well and are now exploring some new add- on technology such as an object- relational mapper, a view engine, a testing library, etc., because the creator of that technology may have also created a scaffolding package for it. If your work involves repeatedly creating similar classes or files of some sort, because you can create custom scaffolders that output test fixtures, deployment scripts, or whatever else you need. Everyone on your team can use your custom scaffolders, too. Other features in Mvc. Scaffolding include: Support for C# and VB projects Support for the Razor and ASPX view engines Supports scaffolding into ASP. NET MVC areas and using custom view layouts/masters You can easily customize the output by editing T4 templates You can add entirely new scaffolders using custom Power. Shell logic and custom T4 templates. These (and any custom parameters you. You can get Nu. Get packages containing additional scaffolders for different technologies (e. Download ASP.NET MVC and learn how to build web apps using the model view controller pattern. Internationalization and Localization in ASP.NET MVC 3. Applied ASP.NET MVC 3 in Context Published 5 years ago by Ashic Mahtab, Apress. ASP.NET MVC 3 is the latest sensation in the world of Microsoft Web development. It represents a paradigm shift in the way ASP.NET applications.
By default, this scaffolds data access code using EF Code First. Add Controller Dialog supports extensible scaffolds via Nu. Get packages such as Mvc. Scaffolding. This allows plugging in custom scaffolds into the dialog which would allow you to create scaffolds for other data access technologies such as NHibernate or even JET with ODBCDirect if you! For more information about Scaffolding in ASP. NET MVC 3, see the following resources: HTML 5 Project Templates. The New Project dialog includes a checkbox enable HTML 5 versions of project templates. These templates leverage Modernizr 1. HTML 5 and CSS 3 in down- level browsers. The Razor View Engine. ASP. NET MVC 3 comes with a new view engine named Razor that offers the following benefits: Razor syntax is clean and concise, requiring a minimum number of keystrokes. Razor is easy to learn, in part because it's based on existing languages like C# and Visual Basic. Visual Studio includes Intelli. Sense and code colorization for Razor syntax. Razor views can be unit tested without requiring that you run the application or launch a web server. Some new Razor features include the following: @model syntax for specifying the type being passed to the view. The ability to specify defaults (such as layoutpage) once for an entire site. The Html. Raw method for displaying text without HTML- encoding it. Support for sharing code among multiple views (. Razor also includes new HTML helpers, such as the following: Chart. Renders a chart, offering the same features as the chart control in ASP. NET 4. Renders a data grid, complete with paging and sorting functionality. Uses hashing algorithms to create properly salted and hashed passwords. Sends an email message. For more information about Razor, see the following resources: Support for Multiple View Engines. The 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 Filters. Sometimes 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 Global. Filters collection. For more information about global action filters, see the following resources: New . In MVC 3, you can also use somewhat simpler syntax with the View. Bag property to accomplish the same purpose. For example, instead of writing View. Data. You do not need to define any strongly- typed classes to use the View. Bag 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, View. Bag properties are stored as name/value pairs in the View. Data dictionary. Returns a 4. HTTP status code to the client. Returns a temporary redirect (HTTP 3. HTTP 3. 01 status code), depending on a Boolean parameter. In conjunction with this change, the Controller class now has three methods for performing permanent redirects: Redirect. Permanent, Redirect. To. Route. Permanent, and Redirect. To. Action. Permanent. These methods return an instance of Redirect. Result with the Permanent property set to true. Returns a user- specified HTTP status code. Java. Script and Ajax Improvements. By default, Ajax and validation helpers in MVC 3 use an unobtrusive Java. Script approach. Unobtrusive Java. Script avoids injecting inline Java. Script into HTML. This makes your HTML smaller and less cluttered, and makes it easier to swap out or customize Java. Script libraries. Validation helpers in MVC 3 also use the j. Query. Validate plugin by default. If you want MVC 2 behavior, you can disable unobtrusive Java. Script using a web. For more information about Java. Script and Ajax improvements, see the following resources: Client- Side Validation. Enabled by Default. In earlier versions of MVC, you need to explicitly call the Html. Enable. Client. Validation method from a view in order to enable client- side validation. In MVC 3 this is no longer required because client- side validation is enabled by default. You can host those libraries on your own server or reference them from a content delivery network (CDN) like the CDNs from Microsoft or Google. Remote Validator. ASP. NET MVC 3 supports the new Remote. Attribute class that enables you to take advantage of the j. Query Validation plug- in's remote validator support. This enables the client- side validation library to automatically call a custom method that you define on the server in order to perform validation logic that can only be done server- side. In the following example, the Remote attribute specifies that client validation will call an action named User. Name. Available on the Users. Controller class in order to validate the User. Name field. This capability is useful in scenarios involving client templates and data binding. For more information about JSON binding support, see the Java. Script and AJAX Improvements section of Scott Guthrie's MVC 3 Preview blog post. Model Validation Improvements. This enables richer scenarios where you can validate the current value based on another property of the model. For example, the new Compare. Attribute attribute lets you compare the values of two properties of a model. In the following example, the Compare. Password property must match the Password field in order to be valid. User. . MVC 3 now retrieves errors from the IValidatable. Object interface when model binding, and automatically flags or highlights affected fields within a view using the built- in HTML form helpers. The IClient. Validatable interface enables ASP. NET MVC to discover at run time whether a validator has support for client validation. This interface has been designed so that it can be integrated with a variety of validation frameworks. For more information about validation interfaces, see the Model Validation Improvements section of Scott Guthrie's MVC 3 Preview blog post. Support for DI has been added in the following areas: Controllers (registering and injecting controller factories, injecting controllers). Views (registering and injecting view engines, injecting dependencies into view pages). Action filters (locating and injecting filters). Model binders (registering and injecting). Model validation providers (registering and injecting). Model metadata providers (registering and injecting). Value providers (registering and injecting). MVC 3 supports the Common Service Locator library and any DI container that supports that library's IService. Locator interface. It also supports a new IDependency. Resolver interface that makes it easier to integrate DI frameworks. For more information about DI in MVC 3, see the following resources: Other New Features. Nu. Get Integration. ASP. NET MVC 3 automatically installs and enables Nu. Get as part of its setup. Nu. Get is a free open- source package manager that makes it easy to find, install, and use . NET libraries and tools in your projects. It works with all Visual Studio project types (including ASP. NET Web Forms and ASP. NET MVC). Nu. Get enables developers who maintain open source projects (for example, projects like Moq, NHibernate, Ninject, Structure. Map, NUnit, Windsor, Rhino. Mocks, and Elmah) to package their libraries and register them in an online gallery. It is then easy for . NET developers who want to use one of these libraries to find the package and install it in projects they are working on. With the ASP. NET 3 Tools Update, project templates include Java. Script libraries pre- installed Nu. Get packages, so they are updatable via Nu. Get. Entity Framework Code First is also pre- installed as a Nu. Get package. For more information about Nu. Get, see the Nu. Get documentation on the Code. Plex site. Partial- Page Output Caching. ASP. NET MVC has supported output caching of full page responses since version 1. MVC 3 also supports partial- page output caching, which allows you to easily cache regions or fragments of a response. For more information about caching, see the Partial Page Output Caching section of Scott Guthrie's blog post on the MVC 3 release candidate and the Child Action Output Caching section of the MVC 3 Release Notes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |