Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning ASP.NET Core MVC Programming

You're reading from  Learning ASP.NET Core MVC Programming

Product type Book
Published in Nov 2016
Publisher Packt
ISBN-13 9781786463838
Pages 326 pages
Edition 1st Edition
Languages
Authors (2):
Mugilan T. S. Ragupathi Mugilan T. S. Ragupathi
Profile icon Mugilan T. S. Ragupathi
Anuraj Parameswaran Anuraj Parameswaran
Profile icon Anuraj Parameswaran
View More author details

Table of Contents (18) Chapters

Learning ASP.NET Core MVC Programming
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Introduction to ASP.NET Core 2. Setting Up the Environment 3. Controllers 4. Views 5. Models 6. Validation 7. Routing 8. Beautifying ASP.NET MVC Applications with Bootstrap 9. Deployment of ASP.NET Core Application 10. Building HTTP-based Web Services Using ASP.NET Web API 11. Improving Performance of an ASP.NET Core Application 12. ASP.NET Core Identity

Our first Controller


Before creating the Controller, we need to remove the following app.Run statement as this will return Hello World! for all the incoming requests. As we want incoming requests to be handled by the controllers, we need to remove the following code from the Configure method of the Startup class:

app.Run(async (context) => { 
  await context.Response.WriteAsync("Hello World!"); 
}); 

We have installed the ASP.NET Core in our application. So, we are geared up to creating our first ASP.NET Core controller. Create a folder with the name Controllers and add a new Controller by selecting from the context menu as shown in the following screenshot:

Once you select Add | New Item, you will be shown the following list of options. We are going to add an MVC controller class to our project:

A class will be created with the following content:

public class HomeController : Controller { 
  // GET: /<controller>/ 
  public IActionResult Index() { 
...
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 $15.99/month. Cancel anytime}