Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
ASP.NET Core MVC 2.0 Cookbook
ASP.NET Core MVC 2.0 Cookbook

ASP.NET Core MVC 2.0 Cookbook: Effective ways to build modern, interactive web applications with ASP.NET Core MVC 2.0

Arrow left icon
Profile Icon Belkheraz Profile Icon Polat Profile Icon Jason De Oliveira
Arrow right icon
€41.99
Paperback Feb 2018 668 pages 1st Edition
eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Belkheraz Profile Icon Polat Profile Icon Jason De Oliveira
Arrow right icon
€41.99
Paperback Feb 2018 668 pages 1st Edition
eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

ASP.NET Core MVC 2.0 Cookbook

Visual Studio 2017, C# 6, IDEs, and Roslyn

In this chapter, we will cover:

  • Working with Visual Studio 2017
  • Working with Visual Studio Code
  • Installing and using OmniSharp on macOS
  • Installing and using OmniSharp on Linux
  • Working with Roslyn
  • Using new C# 6 features

Introduction

In this chapter, we will learn about the most interesting new features of Visual Studio 2017.
We will use Visual Studio Code as a cross-platform editor for C# and some other languages.

We will install the OmniSharp library to have the benefits of intellisense and language support, just as VS does, on other IDEs on macOS and Linux.

We will also discover the new open source and cross-platform compiler named Roslyn, and will understand what its different APIs will bring to us.

Finally, we will discover some useful and relevant new C# 6 features.

Working with Visual Studio 2017

There are many new or enhanced features in VS 2017. Let's have a look at a few of them.

How to do it...

  1. Feature one—VS project templates:
    1. We will find a large number of project templates and samples by going to Menu | File | New Project | Installed.
    2. Select a project template related to the technology or language you want to develop with.
    3. We can also download a lot of project templates by going to Menu | File | New Project | Online.
    4. You can search for a template that matches with a technology.

We want to use all the projects which are not necessarily reliable, so it's up to us to verify that. The New Project dialog box appears:

  1. Visual Studio Gallery to add extensions...

Working with Visual Studio Code

VS Code is a cross-platform, command-line, and file-folder editor. It can be installed on Windows, Linux, or macOS. We can see VS Code as a cross-platform, lightweight version of VS.

Getting ready

How to do it...

  1. Let's launch VS Code by double-clicking on Code in the VSCode-linux-x64 folder:

This will open VS Code:

We can press F1 to make the command palette appear, which gives you access to all the functionality of VS Code.

This way, you can also browse...

Installing and using OmniSharp on macOS

This recipe explains what OmniSharp is, how to install it, and how it is used on macOS.

How to do it...

In most of the previously mentioned text editors, a package manager is included and will be used to install the OmniSharp package:

  1. Edit code on macOS with Atom:
  1. Let's install the OmniSharp package on Atom:
  1. Next, let's create a new project:
  1. Now that OmniSharp is installed, we can use the project scaffolding for .NET projects:
  1. After choosing Web Application, the project and the associated files are generated.
  1. We can see the Startup.cs class generated:

At the bottom of the picture, we can see the OmniSharp features on Atom, with the little green OmniSharp icon...

Installing and using OmniSharp on Linux

In this recipe, we will install and use OmniSharp with the Atom IDE on Linux.

Getting ready

For this recipe, we will use Ubuntu 14.04 VM. We have to make sure that we have followed recipe three to ensure Mono, DNVM, and the Kestrel web server are installed.

How to do it...

  1. First, let's add a repository:
sudo add-apt-get repository ppa:webudp8team/atom
  1. Next, we update the repository:
sudo apt-get update
  1. After that, we install Atom:
sudo apt-get install atom
  1. Now we can launch Atom by typing atom in the command line...

Working with Roslyn

We often think about a compiler as a black box which produces an output from an input. Compilers were generally written in C++ because of speed, custom memory, file, and thread management needs. For example, the C# compiler takes .cs files in input and generates .dll files in output.

Now the new Microsoft compiler written in C# and VB, Roslyn, is not just a compiler; it's a .NET compiler platform that we can extend.

Getting ready

Learning to use all Roslyn APIs could be the subject of an entire book. In this recipe, we will just manipulate one of these APIs: the Syntax Trees API. We will create a Syntax Tree and we will analyze it.

...

Using C# 6 new features

In this recipe, we will discover some of the new features in C# 6.

How to do it...

  1. Feature one—auto initializer for properties:

Before C# 6, we should initialize a property with a value in the class constructor. There is no point in time before the class constructor, so we should use it. Thanks to C# 6 syntax, we can now initialize a property with a value right on the declaration line. No need to use constructor anymore:

    • Before:
public class Person
{
Public class Name {get;set;}
Public Person(){
Name = "Stephane";
}
}
    • Now:
Public string Name {get;set;} = "Stephane";
  1. Feature two—auto initializer for static properties:

Auto initializers can be applied to...

Left arrow icon Right arrow icon

Key benefits

  • • Practical solutions to recurring issues in the web development world
  • • Recipes on the latest features of ASP.Net Core 2.0
  • • Coverage of Bootstrap, Angular, and JavaScript lets you supercharge your frontend

Description

The ASP.NET Core 2.0 Framework has been designed to meet all the needs of today’s web developers. It provides better control, support for test-driven development, and cleaner code. Moreover, it’s lightweight and allows you to run apps on Windows, OSX and Linux, making it the most popular web framework with modern day developers. This book takes a unique approach to web development, using real-world examples to guide you through problems with ASP.NET Core 2.0 web applications. It covers Visual Studio 2017- and ASP.NET Core 2.0-specifc changes and provides general MVC development recipes. It explores setting up .NET Core, Visual Studio 2017, Node.js modules, and NuGet. Next, it shows you how to work with Inversion of Control data pattern and caching. We explore everyday ASP.NET Core MVC 2.0 patterns and go beyond it into troubleshooting. Finally, we lead you through migrating, hosting, and deploying your code. By the end of the book, you’ll not only have explored every aspect of ASP.NET Core MVC 2.0, you’ll also have a reference you can keep coming back to whenever you need to get the job done.

Who is this book for?

This book is written for the ASP.NET developer who wants to deliver professional-standard software, quickly and efficiently. It's filled with hands-on recipes, practical advice, and guidance to help developers with every aspect of the ASP.NET development cycle. Whether you've just started out or are a seasoned pro, the Asp.Net Core 2.0 Cookbook is written for you.

What you will learn

  • • Build ASP.Net Core 2.0 applications using HTTP services with WebApi
  • • Learn to unit-test, load test, and perform test applications using client-side and server-side frameworks
  • • Debug, monitor and troubleshoot ASP.Net Core 2.0 applications using popular tools
  • • Reuse components with NuGet and create modular components with middleware
  • • Create applications using client-side technologies such as HTML5, JavaScript, jQuery, and Angular
  • • Build responsive and dynamic UIs for your MVC apps using Bootstrap
  • • Leverage tools like Karma, Jasmine, QUnit, xUnit, Selenium, Microsoft Fakes, and Visual Studio 2017 Enterprise
Estimated delivery fee Deliver to Cyprus

Premium delivery 7 - 10 business days

€32.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 27, 2018
Length: 668 pages
Edition : 1st
Language : English
ISBN-13 : 9781785886751
Vendor :
Microsoft
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to Cyprus

Premium delivery 7 - 10 business days

€32.95
(Includes tracking information)

Product Details

Publication date : Feb 27, 2018
Length: 668 pages
Edition : 1st
Language : English
ISBN-13 : 9781785886751
Vendor :
Microsoft
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 115.97
Learning ASP.NET Core 2.0
€36.99
ASP.NET Core 2 and Angular 5
€36.99
ASP.NET Core MVC 2.0 Cookbook
€41.99
Total 115.97 Stars icon

Table of Contents

20 Chapters
Cross-Platform with .NET Core Chevron down icon Chevron up icon
Visual Studio 2017, C# 6, IDEs, and Roslyn Chevron down icon Chevron up icon
Working with npm, Frontend Package Managers, and Task Runners Chevron down icon Chevron up icon
Reusing Code with NuGet Chevron down icon Chevron up icon
SOLID Principles, Inversion of Control, and Dependency Injection Chevron down icon Chevron up icon
Data Access - EF7 with Repository, SQL Server, and Stored Procedures Chevron down icon Chevron up icon
Accessing data with Micro ORMs, NoSQL, and Azure Chevron down icon Chevron up icon
Cache and Session - Distributed, Server, and Client Chevron down icon Chevron up icon
Routing Chevron down icon Chevron up icon
ASP.NET Core MVC Chevron down icon Chevron up icon
Web API Chevron down icon Chevron up icon
Filters Chevron down icon Chevron up icon
Views, Models, and ViewModels Chevron down icon Chevron up icon
Razor and Views Chevron down icon Chevron up icon
TagHelpers and ViewComponents Chevron down icon Chevron up icon
OWIN and Middleware Chevron down icon Chevron up icon
Security Chevron down icon Chevron up icon
Frontend Development Chevron down icon Chevron up icon
Deployment and Hosting Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should recei