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

Route attribute at the controller level


You will notice that, with the URL pattern for the action methods, Index and Index2, we repeat the controller name, Home, in both URL patterns, Home and Home/Index3. Instead of repeating the controller method name (or any common part in the URL) at the action method level, we can define it at the controller level.

In the following code, the common part of the URL (Home) is defined at the controller level and the unique part is defined at the action method level. When the URL pattern is getting mapped to the action methods of the controller, both route parts (at the controller level and at the action method level) are merged and matched. So there will be no difference between the routes defined earlier and those that follow.

If you want two parameters in attribute-based routing, you can pass them within curly braces. In the following example, we did this for the SayHello action method.

For example, the URL pattern http://localhost:49831/Home/Index3, will...

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}