Book Image

C# 6 and .NET Core 1.0

Book Image

C# 6 and .NET Core 1.0

Overview of this book

With the release of .NET Core 1.0, you can now create applications for Mac OS X and Linux, as well as Windows, using the development tools you know and love. C# 6 and .NET Core 1.0 has been divided into three high-impact sections to help start putting these new features to work. First, we'll run you through the basics of C#, as well as object-orient programming, before taking a quick tour through the latest features of C# 6 such as string interpolation for easier variable value output, exception filtering, and how to perform static class imports. We'll also cover both the full-feature, mature .NET Framework and the new, cross-platform .NET Core. After quickly taking you through C# and how .NET works, we'll dive into the internals of the .NET class libraries, covering topics such as performance, monitoring, debugging, internationalization, serialization, and encryption. We'll look at Entity Framework Core 1.0 and how to develop Code-First entity data models, as well as how to use LINQ to query and manipulate that data. The final section will demonstrate the major types of applications that you can build and deploy cross-device and cross-platform. In this section, we'll cover Universal Windows Platform (UWP) apps, web applications, and web services. Lastly, we'll help you build a complete application that can be hosted on all of today's most popular platforms, including Linux and Docker. By the end of the book, you'll be armed with all the knowledge you need to build modern, cross-platform applications using C# and .NET Core.
Table of Contents (25 chapters)
C# 6 and .NET Core 1.0
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 14 – Building Web Applications and Services Using ASP.NET Core


  1. What is the difference between a web browser and a web server?

    A web browser makes HTTP requests for resources and a web server sends HTTP responses back containing a mix of HTML, CSS, JavaScript, and other media formats, which the browser then displays to the end user.

  2. What is the difference between a URI, a URL, and a URN?

    Uniform Resource Identifier (URI) is the more general term instead of URL or URN. A Uniform Resource Locator (URL) is a type of URI that species a location of a resource. A Uniform Resource Name (URN) is intended to serve as persistent, location-independent identifier.

  3. What are the four most common HTTP methods?

    The GET, POST, PUT, and DELETE are the most common HTTP methods.

  4. What does it mean when a web server responds with status code 302?

    The web server is indicating a temporary redirect. This means that the web server found the resource but it is at a different location. A response header is used to tell the web browser about the new location. Note that status code 301 is similar but represents a permanent redirect.

  5. What are the responsibilities of a route?

    At the minimum, a route must provide the name of a controller and an action. It can also provide additional parameter values defined in segments.

  6. What are the responsibilities of a controller?

    A controller (and one of its actions) must examine the request and decide which model needs to be passed to which view and then return the response to the client.

  7. What are the responsibilities of a model?

    A model represents all the data required for a particular request.

  8. What are the responsibilities of a view?

    A view converts a model into another format, typically HTML, but it could be any media type, for example, JPEG, DOCX, JSON, XML, and so on.

  9. How does ASP.NET distinguish a request for MVC from a request for Web API?

    Multiple entries are added to the route table. By convention, Web API controllers should use attributes to register routes that look for URLs that begin with api/. If a URL doesn't begin with api/ then it should match other routes registered by MVC.

  10. What data formats does Web API support by default?

    x-www-formurlencoded, JSON, and XML.