Skip to content

Commit

Permalink
Merge pull request #55 from nbarbettini/update-1.1
Browse files Browse the repository at this point in the history
Update 1.1
  • Loading branch information
nbarbettini authored May 3, 2018
2 parents ff6247c + 5590c45 commit b0c8344
Show file tree
Hide file tree
Showing 47 changed files with 795 additions and 692 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_book/
_ebook/
*.pdf
output/
node_modules/
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# How to contribute

First things first: the Little ASP.NET Core Book is licensed under the [Creative Commons Attribution](https://creativecommons.org/licenses/by/4.0/) license, which means you are welcome to copy, redistribute, fork, or remix the material in the book as much as you want. All I ask is that you give credit to the original author (me).
First things first: the Little ASP.NET Core Book is licensed under the [Creative Commons Attribution](https://creativecommons.org/licenses/by/4.0/) license, which means you are welcome to copy, redistribute, fork, or remix the material in the book as much as you want. All I ask is that you give credit to the original author (Nate Barbettini).

## Notice a problem?

If you see a typo or a code error, feel free to fix it. Pull requests are gladly accepted! If you're not familiar or comfortable with Git, that's fine. [File an issue](https://github.com/nbarbettini/little-aspnetcore-book/issues) to point out the error. Please be as detailed as possible.
If you see a typo or a code error, feel free to fix it. Pull requests are gladly accepted!

If you're not familiar or comfortable with Git, that's fine. [File an issue](https://github.com/nbarbettini/little-aspnetcore-book/issues) to point out the error. Please be as detailed as possible.

## Suggestions are welcome

Expand Down
51 changes: 29 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
# Introduction
Thanks for picking up the Little ASP.NET Core Book! I wrote this short book to help developers and people interested in web programming learn about ASP.NET Core 2.0, a new framework for building web applications and APIs.
# The Little ASP.NET Core Book

The Little ASP.NET Core Book is structured as a tutorial. You'll build a to-do app from start to finish and learn:
*by Nate Barbettini*

Copyright © 2018. All rights reserved.

ISBN: 978-1-387-75615-5

Released under the Creative Commons Attribution 4.0 license. You are free to share, copy, and redistribute this book in any format, or remix and transform it for any purpose (even commercially). You must give appropriate credit and provide a link to the license.

For more information, visit https://creativecommons.org/licenses/by/4.0/

## Introduction
Thanks for picking up The Little ASP.NET Core Book! I wrote this short book to help developers and people interested in web programming learn about ASP.NET Core, a new framework for building web applications and APIs.

The Little ASP.NET Core Book is structured as a tutorial. You'll build an application from start to finish and learn:

* The basics of the MVC (Model-View-Controller) pattern
* How front-end code (HTML, CSS, JavaScript) works together with back-end code
* What dependency injection is and why it's useful
* How to read and write data to a database
* How to add log-in, registration, and security
* How to deploy the app to the web
* How to deploy the application to the web

Don't worry, you don't need to know anything about ASP.NET Core (or any of the above) to get started.

## Before you begin

The code for the finished version of the application you'll build is available on GitHub (https://www.github.com/nbarbettini/little-aspnetcore-todo). Feel free to download it if you want to compare as you write your own code.
The code for the finished version of the application you'll build is available on GitHub:

https://www.github.com/nbarbettini/little-aspnetcore-todo

Feel free to download it if you want to see the finished product, or compare as you write your own code.

The book itself is updated frequently with bug fixes and new content. If you're reading a PDF, e-book, or print version, check the official website ([littleasp.net/book](http://www.littleasp.net/book)) to see if there's an updated version available. The very last page of the book contains version information and a changelog.

### Reading in your own language

Thanks to some fantastic multilingual folks, the Little ASP.NET Core Book has been translated into other languages:

{% if output.name === "website" %}
Thanks to some fantastic multilingual contributors, the Little ASP.NET Core Book has been translated into other languages:

* [**ASP.NET Core El Kitabı**](https://sahinyanlik.gitbooks.io/kisa-asp-net-core-kitabi/) (Turkish)

* [**简明 ASP.NET Core 手册**](https://windsting.github.io/little-aspnetcore-book/book/) (Chinese)

{% else %}

**Turkish** - https://sahinyanlik.gitbooks.io/kisa-asp-net-core-kitabi/

**Chinese** - https://windsting.github.io/little-aspnetcore-book/book/

{% endif %}

## Who this book is for
If you're new to programming, this book will introduce you to the patterns and concepts used to build modern web applications. You'll learn how to build a web app (and how the big pieces fit together) by building something from scratch! While this little book won't be able to cover absolutely everything you need to know about programming, it'll give you a starting point so you can learn more advanced topics.
Expand All @@ -43,7 +50,7 @@ If you already code in a backend language like Node, Python, Ruby, Go, or Java,

If you're an ASP.NET MVC developer, you'll feel right at home! ASP.NET Core adds some new tools and reuses (and simplifies) the things you already know. I'll point out some of the differences below.

No matter what your previous experience with web programming, this book will teach you everything you need to create a simple and useful web application in ASP.NET Core. You'll learn how to build functionality using backend and frontend code, how to interact with a database, and how to test and deploy the app to the world.
No matter what your previous experience with web programming, this book will teach you everything you need to create a simple and useful web application in ASP.NET Core. You'll learn how to build functionality using backend and frontend code, how to interact with a database, and how to deploy the app to the world.

## What is ASP.NET Core?
ASP.NET Core is a web framework created by Microsoft for building web applications, APIs, and microservices. It uses common patterns like MVC (Model-View-Controller), dependency injection, and a request pipeline comprised of middleware. It's open-source under the Apache 2.0 license, which means the source code is freely available, and the community is encouraged to contribute bug fixes and new features.
Expand All @@ -57,23 +64,23 @@ There are a lot of great web frameworks to choose from already: Node/Express, Sp

* **Ecosystem.** ASP.NET Core may be new, but .NET has been around for a long time. There are thousands of packages available on NuGet (the .NET package manager; think npm, Ruby gems, or Maven). There are already packages available for JSON deserialization, database connectors, PDF generation, or almost anything else you can think of.

* **Security.** The team at Microsoft takes security seriously, and ASP.NET Core is built to be secure from the ground up. It handles things like sanitizing input data and preventing cross-site request forgery (XSRF) automatically, so you don't have to. You also get the benefit of static typing with the .NET compiler, which is like having a very paranoid linter turned on at all times. This makes it harder to do something you didn't intend with a variable or chunk of data.
* **Security.** The team at Microsoft takes security seriously, and ASP.NET Core is built to be secure from the ground up. It handles things like sanitizing input data and preventing cross-site request forgery (CSRF) attacks, so you don't have to. You also get the benefit of static typing with the .NET compiler, which is like having a very paranoid linter turned on at all times. This makes it harder to do something you didn't intend with a variable or chunk of data.

## .NET Core and .NET Standard
Throughout this book, you'll be learning about ASP.NET Core (the web framework). I'll occasionally mention the .NET runtime (the supporting library that runs .NET code).
Throughout this book, you'll be learning about ASP.NET Core (the web framework). I'll occasionally mention the .NET runtime, the supporting library that runs .NET code. If this already sounds like Greek to you, just skip to the next chapter!

You may also hear about .NET Core and .NET Standard. The naming gets confusing, so here's a simple explanation:

**.NET Standard** is a platform-agnostic interface that defines what features and APIs are available in .NET. .NET Standard doesn't represent any actual code or functionality, just the API definition. There are different "versions" or levels of .NET Standard that reflect how many APIs are available (or how wide the API surface area is). For example, .NET Standard 2.0 has more APIs available than .NET Standard 1.5, which has more APIs than .NET Standard 1.0.
**.NET Standard** is a platform-agnostic interface that defines features and APIs. It's important to note that .NET Standard doesn't represent any actual code or functionality, just the API definition. There are different "versions" or levels of .NET Standard that reflect how many APIs are available (or how wide the API surface area is). For example, .NET Standard 2.0 has more APIs available than .NET Standard 1.5, which has more APIs than .NET Standard 1.0.

**.NET Core** is the .NET runtime that can be installed on Windows, Mac, or Linux. It implements the APIs defined in the .NET Standard interface with the appropriate platform-specific code on each operating system. This is what you'll install on your own machine to build and run ASP.NET Core applications.

And just for good measure, **.NET Framework** is a different implementation of .NET Standard that is Windows-only. This was the only .NET runtime until .NET Core came along and opened .NET up to Mac and Linux. ASP.NET Core can also run on Windows-only .NET Framework, but I won't touch on this too much.
And just for good measure, **.NET Framework** is a different implementation of .NET Standard that is Windows-only. This was the only .NET runtime until .NET Core came along and brought .NET to Mac and Linux. ASP.NET Core can also run on Windows-only .NET Framework, but I won't touch on this too much.

If you're confused by all this naming, no worries! We'll get to some real code in a bit.

## A note to ASP.NET 4 developers
If you haven't used a previous version of ASP.NET, skip ahead to the next chapter!
If you haven't used a previous version of ASP.NET, skip ahead to the next chapter.

ASP.NET Core is a complete ground-up rewrite of ASP.NET, with a focus on modernizing the framework and finally decoupling it from System.Web, IIS, and Windows. If you remember all the OWIN/Katana stuff from ASP.NET 4, you're already halfway there: the Katana project became ASP.NET 5 which was ultimately renamed to ASP.NET Core.

Expand Down
3 changes: 2 additions & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [Add a service class](chapters/mvc-basics/add-service-class.md)
* [Use dependency injection](chapters/mvc-basics/use-dependency-injection.md)
* [Finish the controller](chapters/mvc-basics/finish-controller.md)
* [Update the layout](chapters/mvc-basics/update-the-layout.md)
* [Add external packages](chapters/add-external-packages/README.md)
* [Use a database](chapters/use-a-database/README.md)
* [Connect to a database](chapters/use-a-database/connect-to-a-database.md)
Expand All @@ -21,10 +22,10 @@
* [Add new to-do items](chapters/add-more-features/add-todo-items.md)
* [Complete items with a checkbox](chapters/add-more-features/complete-with-checkbox.md)
* [Security and identity](chapters/security-and-identity/README.md)
* [Add Facebook login](chapters/security-and-identity/add-facebook-login.md)
* [Require authentication](chapters/security-and-identity/require-authentication.md)
* [Using identity in the application](chapters/security-and-identity/using-identity-in-the-application.md)
* [Authorization with roles](chapters/security-and-identity/authorization-with-roles.md)
* [More resources](chapters/security-and-identity/more-resources.md)
* [Automated testing](chapters/automated-testing/README.md)
* [Unit testing](chapters/automated-testing/unit-testing.md)
* [Integration testing](chapters/automated-testing/integration-testing.md)
Expand Down
4 changes: 3 additions & 1 deletion book.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"title": "The Little ASP.NET Core Book",
"description": "A friendly introduction to building web applications with the ASP.NET Core framework.",
"author": "Nate Barbettini",
"isbn": "978-1-387-75615-5",
"pdf": {
"paperSize": "a5"
"paperSize": "a5",
"fontFamily": "Lato"
},
"plugins": ["expandable-chapters-small", "anchors", "forkmegithub"],
"pluginsConfig": {
Expand Down
10 changes: 6 additions & 4 deletions chapters/add-external-packages/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Add external packages
One of the big advantages of using a mature stack like .NET is that the ecosystem of third-party packages and plugins is huge. Just like other package systems (npm, Maven, RubyGems), you can download and install .NET packages that help with almost any task or problem you can imagine.
One of the big advantages of using a mature ecosystem like .NET is that the number of third-party packages and plugins is huge. Just like other package systems, you can download and install .NET packages that help with almost any task or problem you can imagine.

NuGet is both the package manager tool and the official package repository (at https://www.nuget.org). You can search for NuGet packages on the web, and install them from your local machine through the terminal (or the GUI, if you're using Visual Studio).

Expand All @@ -8,9 +8,11 @@ At the end of the last chapter, the to-do application displayed to-do items like

![Dates in ISO 8601 format](iso8601.png)

The due date column is displaying dates in a format that's good for machines (called ISO 8601), but clunky for humans. Wouldn't it be nicer if it simply read "X days from now"? You could write code that converted a date into a human-friendly string, but fortunately, there's a faster way.
The due date column is displaying dates in a format that's good for machines (called ISO 8601), but clunky for humans. Wouldn't it be nicer if it simply read "X days from now"?

The Humanizer package on NuGet (https://www.nuget.org/packages/Humanizer) solves this problem by providing methods that can "humanize" or rewrite almost anything: dates, times, durations, numbers, and so on. It's a fantastic and useful open-source project that's published under the permissive MIT license.
You could write code yourself that converted an ISO 8601 date into a human-friendly string, but fortunately, there's a faster way.

The Humanizer package on NuGet solves this problem by providing methods that can "humanize" or rewrite almost anything: dates, times, durations, numbers, and so on. It's a fantastic and useful open-source project that's published under the permissive MIT license.

To add it to your project, run this command in the terminal:

Expand All @@ -26,7 +28,7 @@ To use a package in your code, you usually need to add a `using` statement that

Since Humanizer will be used to rewrite dates rendered in the view, you can use it directly in the view itself. First, add a `@using` statement at the top of the view:

**`Views/Todo/Index.cshtml`**
**Views/Todo/Index.cshtml**

```html
@model TodoViewModel
Expand Down
2 changes: 1 addition & 1 deletion chapters/add-more-features/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Add more features
Now that you've connected to a database using Entity Framework Core, you're ready to add some more features to the application. First, you'll make it possible to mark a to-do item as complete by checking its checkbox.
Now that you've connected to a database using Entity Framework Core, you're ready to add some more features to the application. First, you'll make it possible to add new to-do items using a form.
Loading

0 comments on commit b0c8344

Please sign in to comment.