Book Image

C# 7 and .NET Core 2.0 Blueprints

By : Dirk Strauss, Jas Rademeyer
Book Image

C# 7 and .NET Core 2.0 Blueprints

By: Dirk Strauss, Jas Rademeyer

Overview of this book

.NET Core is a general purpose, modular, cross-platform, and open source implementation of .NET. With the latest release of .NET Core, many more APIs are expected to show up, which will make APIs consistent across .Net Framework, .NET Core, and Xamarin. This step-by-step guide will teach you the essential .NET Core and C# concepts with the help of real-world projects. The book starts with a brief introduction to the latest features of C# 7 and .NET Core 2.0 before moving on to explain how C# 7 can be implemented using the object-oriented paradigm. You'll learn to work with relational data using Entity Framework and see how to use ASP.NET Core practically. This book will show you how .NET Core allows the creations of cross-platform applications. You'll also learn about SignalR to add real-time functionality to your application. Then you will see how to use MongoDB and how to implement MongoDB into your applications. You'll learn about serverless computing and OAuth concepts, along with running ASP.NET Core applications with Docker Compose. This project-based guide uses practical applications to demonstrate these concepts. By the end of the book, you'll be proficient in developing applications using .NET Core 2.0.
Table of Contents (17 chapters)
Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
Index

Showing and telling


It's time. You've created the project, added the libraries, and wrote the code. Now let's see this thing in action.

Running the application

To run the app, hit F5 (or Ctrl + F5 to start without debugging). The app will open in your default browser and you should see this:

Wait. What? We must be missing something here.

Now we could just navigate to the index.html page by changing our URL to localhost:12709/index.html (just check your port number) and we'll be all good.

Instead, let's specify our index.html page as our default launch page.

In the Startup.cs class, in the Configure method, add this line at the top:

app.UseDefaultFiles();

With this little gem, any request to the wwwroot folder (which at any time navigates to your website) will search for one of the following:

  • default.htm
  • default.html
  • index.htm
  • index.html

The first file found will be the file served as your default page. Great!

Now let's run our app again:

Even though our URL still does not show the /index.html part, our...