Professional ASP.NET MVC 5

Professional ASP.NET MVC 5

Jon Galloway

Language: English

Pages: 624

ISBN: 1118794753

Format: PDF / Kindle (mobi) / ePub


ASP.NET MVC insiders cover the latest updates to the technology in this popular Wrox reference

MVC 5 is the newest update to the popular Microsoft technology that enables you to build dynamic, data-driven websites. Like previous versions, this guide shows you step-by-step techniques on using MVC to best advantage, with plenty of practical tutorials to illustrate the concepts. It covers controllers, views, and models; forms and HTML helpers; data annotation and validation; membership, authorization, and security.

  • MVC 5, the latest version of MVC, adds sophisticated features such as single page applications, mobile optimization, and adaptive rendering
  • A team of top Microsoft MVP experts, along with visionaries in the field, provide practical advice on basic and advanced MVC topics
  • Covers controllers, views, models, forms, data annotations, authorization and security, Ajax, routing, ASP.NET web API, dependency injection, unit testing, real-world application, and much more

Professional ASP.NET MVC 5 is the comprehensive resource you need to make the best use of the updated Model-View-Controller technology.

 

 

 

 

 

 

 

 

 

 

 

 

strongly typed service locator for the sample application might have an interface like this: public interface IServiceLocator { IMessagingService GetMessagingService(); } In this case, when you need an implementation of IMessagingService, you know to call GetMessagingService. The method returns exactly IMessagingService, so you won't need to cast the result. You'll notice that I'm showing the service locator as an interface here rather than as a concrete type. Remember that one of your goals is

something you look at and wonder whether it's really the right thing. Is the cast really necessary? Obviously, the unit test needs to have an instance of the ViewResult class so that it can get access to the ViewBag property; that part isn't in question. But can you make a small change to the action code so that the cast is unnecessary? You can, and should: public ViewResult Index() { return View(); } By changing the return value of the action method from the general ActionResult to the

replace the default view engines. In most cases, though, registering a view engine manually is probably unnecessary if it's available on NuGet. For example, to use the Spark view engine, after creating a default ASP.NET MVC 5 project, simply run the NuGet command Install-Package Spark.Web.Mvc. This adds and configures the Spark view engine in your project. You can quickly see it at work by renaming Index.cshtml to Index.spark. Change the markup to the following to display the message defined in

on the T4 system and syntax at http://msdn.microsoft.com/en-us/library/bb126445.aspx. Note Visual Studio just displays T4 templates (files with a .t4 extension) as plain text. A few Visual Studio extensions exist that add enhanced T4 support to Visual Studio 2013. These commonly add syntax highlighting and IntelliSense, as well as a variety of other useful features. I recommend searching the Visual Studio Gallery (http://visualstudiogallery.msdn.microsoft.com/) for T4 and trying a few.

method="post"> POST is the ideal verb for this scenario because you are modifying album information on the server. Html.ValidationSummary The ValidationSummary helper displays an unordered list of all validation errors in the ModelState dictionary. The Boolean parameter you are using (with a value of true) is telling the helper to exclude property-level errors. In other words, you are telling the summary to display only the errors in ModelState associated with the model itself, and exclude any

Download sample

Download