Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C# 7 and .NET Core Cookbook

You're reading from   C# 7 and .NET Core Cookbook Serverless programming, Microservices and more

Arrow left icon
Product type Paperback
Published in Apr 2017
Publisher
ISBN-13 9781787286276
Length 628 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Dirk Strauss Dirk Strauss
Author Profile Icon Dirk Strauss
Dirk Strauss
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. New Features in C# 7.0 FREE CHAPTER 2. Classes and Generics 3. Object-Oriented Programming in C# 4. Code Analyzers in Visual Studio 5. Regular Expressions 6. Working with Files, Streams, and Serialization 7. Making Apps Responsive with Asynchronous Programming 8. High Performance Programming Using Parallel and Multithreading in C# 9. Composing Event-Based Programs Using Reactive Extensions 10. Exploring .NET Core 1.1 11. ASP.NET Core on the MVC Framework 12. Choosing and Using a Source Control Strategy 13. Creating a Mobile Application in Visual Studio 14. Writing Secure Code and Debugging in Visual Studio 15. Creating Microservices on Azure Service Fabric 16. Azure and Serverless Computing

Rendering Views

So far we have been using plain C# classes as Controllers, but it is far more common have your Controllers inherit from the Controller base class which the MVC framework provides. This allows developers to return complex objects from their Controllers, students in our case. These complex return types are returned in a result that implements the IActionResult interface. We can, therefore, return JSON, XML, and even HTML to return to the client. The usage of this and creating Views is what we will be looking at next in this recipe.

Getting ready

Open up the StudentController class and modify it to contain attribute-based routing. Be sure to add the using Microsoft.AspNetCore.Mvc; namespace to the StudentController class. Also, inherit from the Controller...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime