ASP.NET 5Visual Studio 2015 Templates
Bill WolffRob Keiser
June 10, 2015
ASP.NET 5 MVC 6
• Unified programming model– Razor, WebAPI, Web Pages
• Tag helpers– Extend tag semantics– More readable, Angular style markup
• View components– Mini-controllers, replace @Html.Action()
• Service and type filters for IoC
VS 2013 Add Project
• VS 2013– Web form– MVC– Web API
VS 2015 Add Project
• VS 2015– 4.6 MVC 5– 5 MVC 6
MVC 5 Solution
• These folders stay– Properties– References– Controllers– Models– Views
• These do not– App_Data, App_Start, Content, fonts, Scripts
MVC 6 Solution Items
• Project info• Solution level settings• Project to project references
MVC 6 Template
• Solution layout• New folders– wwwroot• Can rename
– Dependencies– Compiler
MVC 5 Root Files
• These go away– Favicon• Move to wwwroot
– Global.asax– Packages.config• Move to project.json
– Startup.cs– Web.Config• Appsettings, connection strings
MVC 6 Root files
• JSON configurations + CSharp – Bower: JS + CSS frameworks– Config: settings, connections– Gulpfile: client build tasks– MessageService: 2 factor auth email– Package: package versions– Project: dependencies, secrets, commands,
frameworks, excludes, scripts– Startup: initialization code
MVC 5 Properties
• C# attributes
MVC 6 Properties
• AppSettings class
MVC 5 References
• Add assemblies
MVC 6 References
• .NET frameworks
MVC 5 App_Data, App_Start
• Local databases
• Startup code– Bundlers– Routes– Filters– Auth
MVC 5 Content, fonts, Scripts
• Content
• Fonts
• Scripts
• All move to wwwroot
MVC 6 wwwroot
• Static files– Styles– Images– Lib• JavaScript frameworks• CSS frameworks
– Favicon• Can rename
MVC 6 Dependencies
• JS build tools– Bower• Client frameworks
– NPM• Node package manager
MVC 6 Compiler folder
• Razor pre-compilation
• MVC 5 > in csproj file– <MvcBuildViews>true</MvcBuildViews>
MVC 5 >
MVC 6 Controllers folder
• Naming convention– Define IActionResults
MVC 6 Migrations folder
• EF code-first database– optional
MVC 6 Models folder
• Data model classes– Annotation hints
MVC 6 Views folder
• Sub folder per controller– _Global imports
– _ViewStart sets layout
MVC 6 Razor views
• CSHTML pages
MVC 6 Razor shared
• _Layout• _LoginPartial• _ValidationScriptsPartial• Errors
New: Environment tag
• Conditional per level• Set library locations
MVC 5 Layout sections
• Bundle render• Explicit ActionLink commands
• Partial pages
• Content placeholder
• Scripts at the end
MVC 6 Layout sections
• AppSettings inject• New link tag helpers
• Async fragments• Content placeholder• Scripts at the end
MVC 6 Add a Page
• Copy an existing Razor view page– Or make a new one
• Rename the page• Add a method to an existing controller• Add menu link on _Layout page