Fully updated to ASP.NET 3.1, ASP.NET Core in Action, Second Edition is a hands-on primer to building cross-platform web applications with your C# and .NET skills. Even if you’ve never worked with ASP.NET you’ll start creating productive cross-platform web apps fast. And don’t worry about late-breaking changes to ASP.NET Core. With this Manning Early Access Program edition you’ll get updates right up until it ships to the printer, so you’re always working with the latest version of the technology.
If you want a great comprehensive book to help you learn ASP.Net Core 3, look no further.
Routing is the process of mapping an incoming request URL to a Razor Page that will execute to generate a response. You can use routing to decouple your URLs from the files in your project and to have multiple URLs map to the same Razor Page.
ASP.NET Core uses two pieces of middleware for routing. The EndpointRoutingMiddleware is added in Startup.cs by calling UseRouting() and the EndpointMiddleware is added by calling UseEndpoints().
The EndpointRoutingMidleware selects which endpoint should be executed by using routing to match the request URL. The EndpointMiddleware executes the endpoint.
Any middleware placed between the calls to UseRouting() and UseEndpoints() can tell which endpoint will be executed for the request.
Route templates define the structure of known URLs in your application. They’re strings with placeholders for variables that can contain optional values and map to Razor Pages or to MVC controller actions.
Route parameters are variable values extracted from a request’s URL.
Route parameters can be optional and can have default values used when they’re missing.
Route parameters can have constraints that restrict the possible values allowed. If a route parameter doesn’t match its constraints, the route isn’t considered a match.
Don’t use route constraints as general input validators. Use them to disambiguate between two similar routes.
Use a catch-all parameter to capture the remainder of a URL into a route value.
You can use the routing infrastructure to generate internal URLs for your application.
The IUrlHelper can be used to generate URLs as a string based on an action name or Razor Page.
You can use the RedirectToAction and RedirectToPage methods to generate URLs while also generating a redirect response.
The LinkGenerator can be used to generate URLs from other services in your application, where you don’t have access to an HttpContext object.
When a Razor Page is executed, a single page handler is invoked based on the HTTP verb of the request, and the value of the handler route value.
If there is no page handler for a request, an implicit page handler is used that renders the Razor view.
You can control the routing conventions used by ASP.NET Core by configuring the RouteOptions object, for example to force all URLs to be lowercase, or to always append a trailing slash.
You can add additional routing conventions for Razor Pages by calling AddRazorPagesOptions() after AddRazorPages() in Startup.cs. These conventions can control how route parameters are displayed or can add additional route templates for specific Razor Pages.
Where possible, avoid customizing the route templates for a Razor Page and rely on the conventions instead.
placing your order...Don't refresh or navigate away from the page.