The book Professional C# and .NET Core 1.0 covers – as the title says – C# 6 and .NET Core 1.0. What does this mean for ASP.NET Web developers? What’s in there for ASP.NET?
The book covers topics that are important for professional programmers using C# and .NET. With this, the book covers the following four parts:
- The C# Language
- .NET Core and the Windows Runtime
- Windows Apps
- Web Applications and Services
Let’s get into the details of these sections.
C# 6 and the .NET Framework
The C# Language covers the syntax features of C#, including collections and asynchronous programming. Of course the C# syntax is important programming ASP.NET Web applications. You can read about new C# 6 features such as the null-conditional operator, string interpolation, expression bodied members, read-only auto properties, the nameof operator, and more.
.NET Core and Windows Runtime
.NET Core and Windows Runtime covers different libraries from .NET Core as well as other features. You can read about features of Visual Studio, unit testing and UI testing. The APIs covered are for diagnostics, tasks and parallel programming, synchronization techniques, files and streams, security, networking, composition, XML and JSON, and localization. I’ve made sure that the code compiles both with the new .NET Core as well as the .NET Framework – as far as possible.
A browser makes HTTP requests to the server. How this can be done is covered in the Networking chapter (chapter 25). This chapter not only covers the client part calling a HTTP server using HttpClient and a HTTP Server using WebListener, but also a HTTP Client using TcpClient – this way you learn abou the foundation of the HTTP protocol.
The Localization chapter (chapter 28) covers cultures and resources which are important for ASP.NET, and also shows localizing ASP.NET Web applications using the new localization service Microsoft.AspNetCore.Localization available with ASP.NET Core.
This section is important for ASP.NET Web developers if you create services that are invoked by .NET clients, e.g. clients using WPF or UWP. In the chapter 31, “Patterns with XAML Apps”, the dependency injection framework Microsoft.Extensions.DependencyInjection is covered in detail. This dependency injection framework is used with ASP.NET Core applications as well that is covered in the last section of the book.
For a simple example covering Microsoft.Extensions.DependencyInjection (just using a Console application), you can also read Dependency Injection with .NET Core.
Web Applications and Services
Now we get to the most important parts of the book for ASP.NET Web developers. This section contains huge information important for ASP.NET Web Developers. Let’s get into this section chapter by chapter.
This chapter covers the foundation of accessing a database with ADO.NET – connection strings, commands, synchronous and asynchronous data access, as well as transactions.
Entity Framework Core
This chapter covers the new version of Entity Framework – Entity Framework Core 1.0. After an introduction to Entity Framework Core you can read about creating a model with relations, using migrations with .NET Core tools, object tracking, updating objects and object trees, including different options for conflict handling as well as using transactions.
Usually you will host a Web application using the Kestrel server running within IIS on Windows or Apache on Linux. You can also create a custom host to host your server. Chapter 39 gives information how you can create a Windows service that starts when the operating system starts. Contrary to many other chapters, this chapter has a focus on Windows and the .NET Framework and doesn’t cover .NET Core. You can, however, use the same classes as shown in this chapter that are part of .NET Core to control services running on Windows.
Tools like the package managers bower and NPM, and the build system gulp are new for .NET developers. They are covered in this book to help you get started with these tools.
I think it’s a lot easier to build up foundations from scratch instead of starting with a full-blown ASP.NET MVC 6 Visual Studio template. This way you can easily understand all the parts of the full-blown ASP.NET MVC 6 Visual Studio template (or projects created from other tools such as yeoman).
ASP.NET MVC 6
Based on ASP.NET Core, Chapter 40 covers all the features from ASP.NET MVC 6. The first project created again is not based on the full-blown ASP.NET MVC 6 template from Visual Studio but instead adds all services and features offered by ASP.NET MVC 6, such as defining routes, creating controllers (as well as POCO controllers), creating views (including Razor, strongly typed views, partial views, layout pages, using dependency injection in views), and more.
This chapter also covers features that didn’t exist in previous ASP.NET MVC versions, such as View Components, and Tag Helpers. Tag Helpers can be used instead of HTML Helpers. The alternative HTML Helpers are available with ASP.NET MVC 6 as well, and thus are covered in this book as well.
The last project created in this chapter makes use of the full-blown ASP.NET MVC 6 Visual Studio template. At that time you know what’s behind the functionality of this template, and can easily create more complex Web applications.
The chapter walks through an empty ASP.NET Core template to add features needed by an ASP.NET MVC application.
ASP.NET Web API
Because ASP.NET MVC 5 had tight coupling to the .NET Framework and the ASP.NET hosting, ASP.NET Web API 2.0 was a framework that was completely decoupled from ASP.NET. This is now different with the new version. The new version of ASP.NET Web API is the same as ASP.NET MVC 6. As the Web API has a separate usage, and can be used both with HTML clients and other clients such as WPF, UWP, or Xamarin, this technology has its own chapter. Chapter 42 covers creating a service, returning JSON or XML, explains REST, and also shows how to create metadata using Swagger, as well as explaining OData.
WebHooks and SignalR
For real-time communication, you can use SignalR and WebHooks. Currently, these technologies are not available with .NET Core, that’s why they are covered using the .NET Framework and ASP.NET 4. The architecture will not look that different when available with ASP.NET Core. However, you can check additional samples for Professional C# when the technology becomes available.
Both of these technologies can be used to inform the “client” about some information from the “server”. Instead of polling by the client to ask for new information from the server, with WebHooks the client itself is a Web application, and the server can invoke requests in the client to inform about tasks going on. This chapter covers writing WebHooks for GitHub and Dropbox, but you can use other providers such as Instagram, Salesforce, Slack, Microsoft Dynamics and others in a similar way.
What’s not covered in the book
This book does not cover ASP.NET Web Forms at all. ASP.NET Web Forms is not part of .NET Core and never will be. Also, ASP.NET MVC 5.x that is delivered with the .NET Framework is not covered in this book. To create new Web applications, I use ASP.NET Core most of the time – just when some libraries you’re dependent on are not available with ASP.NET Core yet, you might be restricted to older versions of this framework. With existing Web applications it also doesn’t make immediate sense to switch to the new framework. ASP.NET Web Forms still got new features with .NET Framework 4.6 and is further maintained. In this case I can recommend the previous edition of the book, Professional C# 5.0 and .NET 4.5.1.
There are some books that only cover ASP.NET – but Professional C# 6 and .NET Core 1.0 has a huge offering for ASP.NET Core Web developers – probably more than many books that cover only ASP.NET Core.
I hope you enjoy the book!
Have fun with programming and learning!
This article just offered some information what’s covered in my books and workshops: