Commit Graph

3770 Commits (7e53e1a380a49dc1bed35314b2244831591cc09d)

Author SHA1 Message Date
Ahmed Yahia fc74a5258c Update routing.md (#9163)
i think it should be "whether" not "where"
2018-10-23 09:37:13 -05:00
Rasto 8acab21019 Document allowing access with one scheme or another (#9010)
Fixes #5542
2018-10-22 22:27:17 -05:00
Mikael Mengistu 31f4e34f67 SignalR Java Client Preview 3 Docs updates (#9112)
Updating for the Preview3 SignalR Java client
[Review link](https://review.docs.microsoft.com/en-us/aspnet/core/signalr/java-client?view=aspnetcore-2.2&branch=pr-en-us-9112)
Fixes https://github.com/aspnet/Docs/issues/9117
2018-10-22 16:52:19 -05:00
Michael Randers-Pehrson c97438abfb Minor language tweak (#9145) 2018-10-22 14:04:25 -05:00
Luke Latham ab292ad0b8
Clarify IISIntegration overrides (#9033) 2018-10-20 09:14:06 -05:00
Rick Anderson c9a8c4b689
Update routing.md (#9125)
* Update routing.md

* Add missing comma
2018-10-19 11:55:51 -10:00
Pranav K c12382315f Update partial.md (#9132)
React to https://github.com/aspnet/Mvc/issues/8617
2018-10-19 16:12:30 -05:00
BrennanConroy 6210895547 Update DataProtection Redis docs (#8984) 2018-10-19 14:45:01 -05:00
Dave Brock 55c8bfb23b Added "Next" to "Search" button (#9118)
I noticed the "Next" button in this tutorial was not prefaced with `Next:` like the rest of the tutorials. This massive pull request resolves this.
2018-10-19 14:27:56 -05:00
Rick Anderson 36e2502ce8
UE edit of Security considerations in ASP.NET Core SignalR (#9088)
[Internal review URL](https://review.docs.microsoft.com/en-us/aspnet/core/signalr/security?view=aspnetcore-2.1&branch=pr-en-us-9088)

- Kill long sentences. Long sentences are difficult for native speakers and impossible for MT (machine translation)
- Format code to prevent horizontal scroll bar on tablets 85 characters wide. You can simulate tablets by viewing in a browser of the maximum width that doesn't have left or right panes (TOC's).
- Prune dead wood. Avoid unnecessary words that don't add meaning to the text.
- Avoid "you" except when it make the statement more clear. 

  - For example, the following CORS policy allows a SignalR browser client hosted on `http://example.com` to access **your** SignalR app:
  -For example, the following CORS policy allows a SignalR browser client hosted on `http://example.com` to access the SignalR app hosted on `http://signalr.example.com`:
- Avoid Wikipedia links
- Code snippets

Explicit sign-off required on my security rewording below:
- [ ]  Allow cross-origin requests only from domains you trust or control. 

The following are slightly too long but I couldn't find an elegant way to shorten them (not that my other trimming was elegant):

- Applications should be configured to validate these headers to ensure that only WebSockets coming from the expected origins are allowed.
2018-10-19 09:10:45 -10:00
Dave Brock 94e7237e26 Grammar fixes (#9122) 2018-10-19 06:54:35 -05:00
Dave Brock 9546de199e Namespace correction (#9123) 2018-10-18 19:42:11 -10:00
Rick Anderson 8b6104beeb
self-closing TH (#9124)
Fixes  #6075
2018-10-18 19:41:18 -10:00
Dave Brock 00260436ce Search enhancements (#9101)
* casing fixes

* image refresh

* updates for #8000

* Update search3.md
2018-10-18 13:40:26 -10:00
Luke Latham 2fe9ca8744 Remove previous Identity Core sample app (#9115)
Fixes #9114 

We're going to keep the cookie sharing auth samples over here on the docs repo and **not** move them to the AuthSamples repo. We don't need to keep the previous Identity Core sample (and it's not linked to anything).
2018-10-18 12:35:06 -10:00
Rick Anderson 3ec2577502
Update dependency-injection.md (#9111) 2018-10-18 11:00:26 -10:00
Tom Dykstra df1548c70b
fix xrefs, finish deleting repo pattern (#9110) 2018-10-18 13:37:28 -07:00
Luke Latham c12f7b04b2
Env var patch in host topics (#9104) 2018-10-18 13:26:04 -05:00
Dave Brock 5509a97557 Moved section earlier in this tutorial (#9063)
A link to the FK section is actually provided, but it is easy to gloss over. Moving the section up in the document prevents users reading it too late to do anything about it, as said in the issue.

Fixes #7728
2018-10-18 08:19:38 -10:00
Rick Anderson 8038921da3 Update dependency-injection.md (#9090)
* Update dependency-injection.md

* Update dependency-injection.md
2018-10-18 14:17:12 -04:00
Luke Latham e88d6d6e86 Description line in the wrong spot (#9103) 2018-10-18 13:02:39 -05:00
Scott Addie b2f79137f1
Merge pull request #9087 from aspnet/scottaddie/rp-partial-view
Add detail about serving partial views named with underscores
2018-10-18 11:34:09 -05:00
Codefridge abc1555e2d Update aspnetcore/security/authorization/razor-pages-authorization/sa… (#9092)
`AuthenticateUser()` now uses the passed in email parameter, instead of the Input class property.

When checking the user entered email address, the `AuthenticateUser()` method was using the bound property `Input`, which is incorrect, the method must use the `email` parameter that is passed into the method.

PS: This is my first pull request, so is the above enough information?
2018-10-18 10:28:01 -05:00
Luke Latham 1f3698ba45 List default services for Generic Host (#9061)
Fixes #8893 

[Internal Review Topic](https://review.docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-2.1&branch=pr-en-us-9061)

* Remove Logging from service config (given it's a default service).
* List the default services (too literal here? ... trimming needed??? 🔪)
2018-10-17 19:58:19 -05:00
Scott Addie 4a56fc9fe1 Add another sentence about @page 2018-10-17 19:39:56 -05:00
Scott Addie 00b6296b45 React to feedback 2018-10-17 19:35:19 -05:00
Scott Addie 6e91c3b28d Verbiage tweak 2018-10-17 17:24:10 -05:00
Scott Addie ccab23fe53 Add detail about serving partial views named with underscores 2018-10-17 17:14:06 -05:00
Andrew Stanton-Nurse 04e2b7a6bd Documentation on WebSocket Origin validation (#9080)
Added some notes on WebSocket Origin validation to ASP.NET Core SignalR documentation.

[Internal Review Link](https://review.docs.microsoft.com/en-us/aspnet/core/signalr/security?view=aspnetcore-2.1&branch=pr-en-us-9080)
2018-10-17 11:01:37 -10:00
Dave Brock 5faa50e2ff Casing fixes (#9065)
Forgot a couple casing issues from the issue the other day.
2018-10-17 13:50:20 -05:00
Tom Dykstra faccb02bf1
retire Repo Pattern and Primitives docs (#9077) 2018-10-17 10:50:50 -07:00
Luke Latham 4bba94bb63
Array support with the AKV configuration provider (#9064) 2018-10-17 12:47:33 -05:00
Scott Addie 017ba68c56
Remove middleware term from ToC link text (#9076)
Removing the "middleware" part of the link text. This was verbally approved by Dan Roth in a meeting yesterday.
2018-10-17 12:20:34 -05:00
Scott Addie 2ef24f316b Retire the Bootstrap doc (#9054)
Fixes https://github.com/aspnet/Docs/issues/3567
Fixes https://github.com/aspnet/Docs/issues/3544
Fixes https://github.com/aspnet/Docs/issues/8375

Per Dan Roth, retire the doc and redirect to the official Bootstrap site.
2018-10-16 17:17:16 -10:00
Luke Latham 6df7ad6613 Repair metadata (#9066) 2018-10-16 17:15:14 -10:00
Rick Anderson 14f4d88c5c
Update startup.md (#9069) 2018-10-16 17:14:16 -10:00
Dave Brock 64bbba1514 Fixed `get` issue in tag helper example (#9062)
* casing fixes

* image refresh
2018-10-16 14:25:31 -10:00
Dave Brock 7905e9981d Add RP to layout (#9016)
I will not lie: this was not enjoyable. With the realization that this page might be shuffled around to a new spot in the TOC, it was a delicate act balancing Razor pages and traditional MVC without getting too intrusive about it.

As such, I:

* Included a note at the top of the document outlining the subtle differences, so I can just casually reference them later and don't have to explain which is which
* Replaced wording of "views" with "pages or views"
* Changed controller wording to "the folder where the handler method (or controller) exists."
I also updated the *_Layout.cshtml* sample file. It's a little different, two years later.

I expect some back-and-forth about this—let me know what you think, @Rick-Anderson.

Fixes #8030
2018-10-16 14:21:31 -10:00
Tom Dykstra 50863ad503 Logging article updates (#8908)
Fixes #5161
Fixes #8338 
Fixes #8620
Fixes #8803 
Fixes #8207

[Internal review link](https://review.docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/index?view=aspnetcore-2.2&branch=pr-en-us-8908)
2018-10-16 09:16:57 -10:00
Dave Brock 42c65ca477 typo fixes (#9058) 2018-10-16 13:52:52 -05:00
James Newton-King 92f7be84b3 Link to MVC and Razor page route conventions (#9042)
* Link to MVC and Razor page route conventions

* Update routing.md

---
title: Routing in ASP.NET Core
author: ardalis
description: Discover how ASP.NET Core routing functionality is responsible for mapping an incoming request to a route handler.
ms.author: riande
ms.custom: mvc
ms.date: 10/01/2018
uid: fundamentals/routing
---
# Routing in ASP.NET Core

By [Ryan Nowak](https://github.com/rynowak), [Steve Smith](https://ardalis.com/), and [Rick Anderson](https://twitter.com/RickAndMSFT)

Routing functionality is responsible for mapping an incoming request to a route handler. Routes are defined in the app and configured when the app starts. A route can optionally extract values from the URL contained in the request, and these values can then be used for request processing. Using route information from the app, the routing functionality is also able to generate URLs that map to route handlers. Therefore, routing can find a route handler based on a URL or the URL corresponding to a given route handler based on route handler information.

> [!IMPORTANT]
> This document covers low-level ASP.NET Core routing. For information on ASP.NET Core MVC routing, see <xref:mvc/controllers/routing>.

[View or download sample code](https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals/routing/samples) ([how to download](xref:tutorials/index#how-to-download-a-sample))

## Routing basics

Routing uses *routes* (implementations of <xref:Microsoft.AspNetCore.Routing.IRouter>) to:

* Map incoming requests to *route handlers*.
* Generate URLs used in responses.

Generally, an app has a single collection of routes. When a request arrives, the route collection is processed in order. The incoming request looks for a route that matches the request URL by calling the <xref:Microsoft.AspNetCore.Routing.IRouter.RouteAsync*> method on each available route in the route collection. By contrast, a response can use routing to generate URLs (for example, for redirection or links) based on route information and thus avoid having to hard-code URLs, which helps maintainability.

Routing is connected to the [middleware](xref:fundamentals/middleware/index) pipeline by the <xref:Microsoft.AspNetCore.Builder.RouterMiddleware> class. [ASP.NET Core MVC](xref:mvc/overview) adds routing to the middleware pipeline as part of its configuration. To learn about using routing as a standalone component, see [Use Routing Middleware](#use-routing-middleware) section.

### URL matching

URL matching is the process by which routing dispatches an incoming request to a *handler*. This process is based on data in the URL path but can be extended to consider any data in the request. The ability to dispatch requests to separate handlers is key to scaling the size and complexity of an app.

Incoming requests enter the `RouterMiddleware`, which calls the <xref:Microsoft.AspNetCore.Routing.IRouter.RouteAsync*> method on each route in sequence. The <xref:Microsoft.AspNetCore.Routing.IRouter> instance chooses whether to *handle* the request by setting the [RouteContext.Handler](xref:Microsoft.AspNetCore.Routing.RouteContext.Handler*) to a non-null <xref:Microsoft.AspNetCore.Http.RequestDelegate>. If a route sets a handler for the request, route processing stops, and the handler is invoked to process the request. If all routes are tried and no handler is found for the request, the middleware calls *next*, and the next middleware in the request pipeline is invoked.

The primary input to `RouteAsync` is the [RouteContext.HttpContext](xref:Microsoft.AspNetCore.Routing.RouteContext.HttpContext*) associated with the current request. The `RouteContext.Handler` and [RouteContext.RouteData](xref:Microsoft.AspNetCore.Routing.RouteContext.RouteData*) are outputs set after a route matches.

A match during `RouteAsync` also sets the properties of the `RouteContext.RouteData` to appropriate values based on the request processing performed thus far. If a route matches a request, the `RouteContext.RouteData` contains important state information about the *result*.

[RouteData.Values](xref:Microsoft.AspNetCore.Routing.RouteData.Values*) is a dictionary of *route values* produced from the route. These values are usually determined by tokenizing the URL and can be used to accept user input or to make further dispatching decisions inside the app.

[RouteData.DataTokens](xref:Microsoft.AspNetCore.Routing.RouteData.DataTokens*) is a property bag of additional data related to the matched route. `DataTokens` are provided to support associating state data with each route so that the app can make decisions later based on which route matched. These values are developer-defined and do **not** affect the behavior of routing in any way. Additionally, values stashed in data tokens can be of any type, in contrast to route values, which must be easily convertible to and from strings.

[RouteData.Routers](xref:Microsoft.AspNetCore.Routing.RouteData.Routers*) is a list of the routes that took part in successfully matching the request. Routes can be nested inside of one another. The `Routers` property reflects the path through the logical tree of routes that resulted in a match. Generally, the first item in `Routers` is the route collection and should be used for URL generation. The last item in `Routers` is the route handler that matched.

### URL generation

URL generation is the process by which routing can create a URL path based on a set of route values. This allows for a logical separation between your handlers and the URLs that access them.

URL generation follows a similar iterative process, but it starts with user or framework code calling into the <xref:Microsoft.AspNetCore.Routing.IRouter.GetVirtualPath*> method of the route collection. Each *route* then has its `GetVirtualPath` method called in sequence until a non-null <xref:Microsoft.AspNetCore.Routing.VirtualPathData> is returned.

The primary inputs to `GetVirtualPath` are:

* [VirtualPathContext.HttpContext](xref:Microsoft.AspNetCore.Routing.VirtualPathContext.HttpContext*)
* [VirtualPathContext.Values](xref:Microsoft.AspNetCore.Routing.VirtualPathContext.Values*)
* [VirtualPathContext.AmbientValues](xref:Microsoft.AspNetCore.Routing.VirtualPathContext.AmbientValues*)

Routes primarily use the route values provided by the `Values` and `AmbientValues` to decide where it's possible to generate a URL and what values to include. The `AmbientValues` are the set of route values that were produced from matching the current request with the routing system. In contrast, `Values` are the route values that specify how to generate the desired URL for the current operation. The `HttpContext` is provided in case a route needs to obtain services or additional data associated with the current context.

> [!TIP]
> Think of [VirtualPathContext.Values](xref:Microsoft.AspNetCore.Routing.VirtualPathContext.Values*) as being a set of overrides for the [VirtualPathContext.AmbientValues](xref:Microsoft.AspNetCore.Routing.VirtualPathContext.AmbientValues*). URL generation attempts to reuse route values from the current request to make it easy to generate URLs for links using the same route or route values.

The output of `GetVirtualPath` is a `VirtualPathData`. `VirtualPathData` is a parallel of `RouteData`. `VirtualPathData` contains the `VirtualPath` for the output URL and some additional properties that should be set by the route.

The [VirtualPathData.VirtualPath](xref:Microsoft.AspNetCore.Routing.VirtualPathData.VirtualPath*) property contains the *virtual path* produced by the route. Depending on your needs, you may need to process the path further. If you want to render the generated URL in HTML, prepend the base path of the app.

The [VirtualPathData.Router](xref:Microsoft.AspNetCore.Routing.VirtualPathData.Router*) is a reference to the route that successfully generated the URL.

The [VirtualPathData.DataTokens](xref:Microsoft.AspNetCore.Routing.VirtualPathData.DataTokens*) properties is a dictionary of additional data related to the route that generated the URL. This is the parallel of [RouteData.DataTokens](xref:Microsoft.AspNetCore.Routing.RouteData.DataTokens*).

### Creating routes

Routing provides the <xref:Microsoft.AspNetCore.Routing.Route> class as the standard implementation of <xref:Microsoft.AspNetCore.Routing.IRouter>. `Route` uses the *route template* syntax to define patterns that match against the URL path when <xref:Microsoft.AspNetCore.Routing.IRouter.RouteAsync*> is called. `Route` uses the same route template to generate a URL when `GetVirtualPath` is called.

Most apps create routes by calling <xref:Microsoft.AspNetCore.Builder.MapRouteRouteBuilderExtensions.MapRoute*> or one of the similar extension methods defined on <xref:Microsoft.AspNetCore.Routing.IRouteBuilder>. All of these methods create an instance of <xref:Microsoft.AspNetCore.Routing.Route> and add it to the route collection.

`MapRoute` doesn't take a route handler parameter. `MapRoute` only adds routes that are handled by the <xref:Microsoft.AspNetCore.Routing.RouteBuilder.DefaultHandler*>. Since the default handler is an `IRouter`, it may decide not to handle the request. For example, ASP.NET Core MVC is typically configured as a default handler that only handles requests that match an available controller and action. To learn more about routing to MVC, see <xref:mvc/controllers/routing>.

The following code example is an example of a `MapRoute` call used by a typical ASP.NET Core MVC route definition:

```csharp
routes.MapRoute(
    name: "default",
    template: "{controller=Home}/{action=Index}/{id?}");
```

This template matches a URL path like `/Products/Details/17` and extracts the route values `{ controller = Products, action = Details, id = 17 }`. The route values are determined by splitting the URL path into segments and matching each segment with the *route parameter* name in the route template. Route parameters are named. They're defined by enclosing the parameter name in braces `{ ... }`.

The preceding template could also match the URL path `/` and would produce the values `{ controller = Home, action = Index }`. This occurs because the `{controller}` and `{action}` route parameters have default values and the `id` route parameter is optional. An equals `=` sign followed by a value after the route parameter name defines a default value for the parameter. A question mark `?` after the route parameter name defines the parameter as optional. Route parameters with a default value *always* produce a route value when the route matches. Optional parameters don't produce a route value if there was no corresponding URL path segment.

See [route-template-reference](#route-template-reference) for a thorough description of route template features and syntax.

This example includes a *route constraint*:

```csharp
routes.MapRoute(
    name: "default",
    template: "{controller=Home}/{action=Index}/{id:int}");
```

This template matches a URL path like `/Products/Details/17` but not `/Products/Details/Apples`. The route parameter definition `{id:int}` defines a [route constraint](#route-constraint-reference) for the `id` route parameter. Route constraints implement <xref:Microsoft.AspNetCore.Routing.IRouteConstraint> and inspect route values to verify them. In this example, the route value `id` must be convertible to an integer. See [route-constraint-reference](#route-constraint-reference) for a more detailed explanation of route constraints that are provided by the framework.

Additional overloads of `MapRoute` accept values for `constraints`, `dataTokens`, and `defaults`. These additional parameters of `MapRoute` are defined as type `object`. The typical usage of these parameters is to pass an anonymously typed object, where the property names of the anonymous type match route parameter names.

The following two examples create equivalent routes:

```csharp
routes.MapRoute(
    name: "default_route",
    template: "{controller}/{action}/{id?}",
    defaults: new { controller = "Home", action = "Index" });

routes.MapRoute(
    name: "default_route",
    template: "{controller=Home}/{action=Index}/{id?}");
```

> [!TIP]
> The inline syntax for defining constraints and defaults can be convenient for simple routes. However, there are features, such as data tokens, that aren't supported by inline syntax.

The following example demonstrates a few more scenarios:

```csharp
routes.MapRoute(
    name: "blog",
    template: "Blog/{*article}",
    defaults: new { controller = "Blog", action = "ReadArticle" });
```

This template matches a URL path like `/Blog/All-About-Routing/Introduction` and extracts the values `{ controller = Blog, action = ReadArticle, article = All-About-Routing/Introduction }`. The default route values for `controller` and `action` are produced by the route even though there are no corresponding route parameters in the template. Default values can be specified in the route template. The `article` route parameter is defined as a *catch-all* by the appearance of an asterisk `*` before the route parameter name. Catch-all route parameters capture the remainder of the URL path and can also match the empty string.

This example adds route constraints and data tokens:

```csharp
routes.MapRoute(
    name: "us_english_products",
    template: "en-US/Products/{id}",
    defaults: new { controller = "Products", action = "Details" },
    constraints: new { id = new IntRouteConstraint() },
    dataTokens: new { locale = "en-US" });
```

This template matches a URL path like `/en-US/Products/5` and extracts the values `{ controller = Products, action = Details, id = 5 }` and the data tokens `{ locale = en-US }`.

![Locals Windows tokens](routing/_static/tokens.png)

### URL generation

The `Route` class can also perform URL generation by combining a set of route values with its route template. This is logically the reverse process of matching the URL path.

> [!TIP]
> To better understand URL generation, imagine what URL you want to generate and then think about how a route template would match that URL. What values would be produced? This is the rough equivalent of how URL generation works in the `Route` class.

This example uses a basic ASP.NET Core MVC style route:

```csharp
routes.MapRoute(
    name: "default",
    template: "{controller=Home}/{action=Index}/{id?}");
```

With the route values `{ controller = Products, action = List }`, this route generates the URL `/Products/List`. The route values are substituted for the corresponding route parameters to form the URL path. Since `id` is an optional route parameter, it's no problem that it doesn't have a value.

With the route values `{ controller = Home, action = Index }`, this route generates the URL `/`. The route values that were provided match the default values so that the segments corresponding to those values can be safely omitted. Both URLs generated round-trip with this route definition and produce the same route values that were used to generate the URL.

> [!TIP]
> An app using ASP.NET Core MVC should use <xref:Microsoft.AspNetCore.Mvc.Routing.UrlHelper> to generate URLs instead of calling into routing directly.

For more information about URL generation, see [url-generation-reference](#url-generation-reference).

## Use Routing Middleware

::: moniker range=">= aspnetcore-2.1"

Reference the [Microsoft.AspNetCore.App metapackage](xref:fundamentals/metapackage-app) in the app's project file.

::: moniker-end

::: moniker range="= aspnetcore-2.0"

Reference the [Microsoft.AspNetCore.All metapackage](xref:fundamentals/metapackage) in the app's project file.

::: moniker-end

::: moniker range="< aspnetcore-2.0"

Reference the [Microsoft.AspNetCore.Routing](https://www.nuget.org/packages/Microsoft.AspNetCore.Routing/) in the app's project file.

::: moniker-end

Add routing to the service container in `Startup.ConfigureServices`:

::: moniker range=">= aspnetcore-2.0"

[!code-csharp[](routing/samples/2.x/RoutingSample/Startup.cs?name=snippet_ConfigureServices&highlight=3)]

::: moniker-end

::: moniker range="< aspnetcore-2.0"

[!code-csharp[](routing/samples/1.x/RoutingSample/Startup.cs?name=snippet_ConfigureServices&highlight=3)]

::: moniker-end

Routes must be configured in the `Startup.Configure` method. The sample app uses these APIs:

* `RouteBuilder`
* `Build`
* `MapGet` &ndash; Matches only HTTP GET requests.
* `UseRouter`

::: moniker range=">= aspnetcore-2.0"

[!code-csharp[](routing/samples/2.x/RoutingSample/Startup.cs?name=snippet_RouteHandler)]

::: moniker-end

::: moniker range="< aspnetcore-2.0"

[!code-csharp[](routing/samples/1.x/RoutingSample/Startup.cs?name=snippet_RouteHandler)]

::: moniker-end

The following table shows the responses with the given URIs.

| URI                  | Response                                          |
| -------------------- | ------------------------------------------------- |
| /package/create/3    | Hello! Route values: [operation, create], [id, 3] |
| /package/track/-3    | Hello! Route values: [operation, track], [id, -3] |
| /package/track/-3/   | Hello! Route values: [operation, track], [id, -3] |
| /package/track/      | &lt;Fall through, no match&gt;                    |
| GET /hello/Joe       | Hi, Joe!                                          |
| POST /hello/Joe      | &lt;Fall through, matches HTTP GET only&gt;       |
| GET /hello/Joe/Smith | &lt;Fall through, no match&gt;                    |

If you're configuring a single route, call <xref:Microsoft.AspNetCore.Builder.RoutingBuilderExtensions.UseRouter*> passing in an `IRouter` instance. You won't need to use <xref:Microsoft.AspNetCore.Routing.RouteBuilder>.

The framework provides a set of extension methods for creating routes, such as:

* `MapRoute`
* `MapGet`
* `MapPost`
* `MapPut`
* `MapDelete`
* `MapVerb`

Some of these methods, such as `MapGet`, require a `RequestDelegate` to be provided. The `RequestDelegate` is used as the *route handler* when the route matches. Other methods in this family allow configuring a middleware pipeline for use as the route handler. If the *Map* method doesn't accept a handler, such as `MapRoute`, then it uses the <xref:Microsoft.AspNetCore.Routing.RouteBuilder.DefaultHandler*>.

The `Map[Verb]` methods use constraints to limit the route to the HTTP Verb in the method name. For example, see <xref:Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions.MapGet*> and <xref:Microsoft.AspNetCore.Routing.RequestDelegateRouteBuilderExtensions.MapVerb*>.

## Route template reference

Tokens within curly braces (`{ ... }`) define *route parameters* that are bound if the route is matched. You can define more than one route parameter in a route segment, but they must be separated by a literal value. For example, `{controller=Home}{action=Index}` isn't a valid route, since there's no literal value between `{controller}` and `{action}`. These route parameters must have a name and may have additional attributes specified.

Literal text other than route parameters (for example, `{id}`) and the path separator `/` must match the text in the URL. Text matching is case-insensitive and based on the decoded representation of the URLs path. To match the literal route parameter delimiter `{` or  `}`, escape it by repeating the character (`{{` or `}}`).

URL patterns that attempt to capture a filename with an optional file extension have additional considerations. For example, consider the template `files/{filename}.{ext?}`. When both `filename` and `ext` exist, both values are populated. If only `filename` exists in the URL, the route matches because the trailing period `.` is  optional. The following URLs match this route:

* `/files/myFile.txt`
* `/files/myFile`

You can use the `*` character as a prefix to a route parameter to bind to the rest of the URI. This is called a *catch-all* parameter. For example, `blog/{*slug}` matches any URI that starts with `/blog` and had any value following it (which is assigned to the `slug` route value). Catch-all parameters can also match the empty string.

::: moniker range=">= aspnetcore-2.2"

The catch-all parameter escapes the appropriate characters when the route is used to generate a URL, including path separator (`/`) characters. For example, the route `foo/{*path}` with route values `{ path = "my/path" }` generates `foo/my%2Fpath`. Note the escaped forward slash. To round-trip path separator characters, use the `**` route parameter prefix. The route `foo/{**path}` with `{ path = "my/path" }` generates `foo/my/path`.

::: moniker-end

Route parameters may have *default values*, designated by specifying the default after the parameter name, separated by an equals sign (`=`). For example, `{controller=Home}` defines `Home` as the default value for `controller`. The default value is used if no value is present in the URL for the parameter. In addition to default values, route parameters may be optional, specified by appending a question mark (`?`) to the end of the parameter name, as in `id?`. The difference between optional values and default route parameters is that a route parameter with a default value always produces a value; an optional parameter has a value only when a value is provided by the request URL.

::: moniker range=">= aspnetcore-2.2"

Route parameters may have constraints, which must match the route value bound from the URL. Adding a colon (`:`) and constraint name after the route parameter name specifies an *inline constraint* on a route parameter. If the constraint requires arguments, they're enclosed in parentheses `( )` after the constraint name. Multiple inline constraints can be specified by appending another colon (`:`) and constraint name. The constraint name and arguments are passed to the <xref:Microsoft.AspNetCore.Routing.IInlineConstraintResolver> service to create an instance of <xref:Microsoft.AspNetCore.Routing.IRouteConstraint> to use in URL processing. If the constraint constructor requires services, they're resolved from dependency injection's app services. For example, the route template `blog/{article:minlength(10)}` specifies a `minlength` constraint with the argument `10`. For more information on route constraints and a listing of the constraints provided by the framework, see the [Route constraint reference](#route-constraint-reference) section.

::: moniker-end

::: moniker range="< aspnetcore-2.2"

Route parameters may have constraints, which must match the route value bound from the URL. Adding a colon (`:`) and constraint name after the route parameter name specifies an *inline constraint* on a route parameter. If the constraint requires arguments, they're enclosed in parentheses `( )` after the constraint name. Multiple inline constraints can be specified by appending another colon (`:`) and constraint name. The constraint name and arguments are passed to the <xref:Microsoft.AspNetCore.Routing.IInlineConstraintResolver> service to create an instance of <xref:Microsoft.AspNetCore.Routing.IRouteConstraint> to use in URL processing. For example, the route template `blog/{article:minlength(10)}` specifies a `minlength` constraint with the argument `10`. For more information on route constraints and a listing of the constraints provided by the framework, see the [Route constraint reference](#route-constraint-reference) section.

::: moniker-end

::: moniker range=">= aspnetcore-2.2"

Route parameters may also have parameter transformers, which transform a parameter's value when generating links and matching actions and pages to URIs. Like constraints, parameter transformers can be added inline to a route parameter by adding a colon (`:`) and transformer name after the route parameter name. For example, the route template `blog/{article:slugify}` specifies a `slugify` transformer.

::: moniker-end

The following table demonstrates some route templates and their behavior.

| Route Template                         | Example Matching URL  | Notes                                                                  |
| -------------------------------------- | --------------------- | ---------------------------------------------------------------------- |
| hello                                  | /hello                | Only matches the single path `/hello`                                  |
| {Page=Home}                            | /                     | Matches and sets `Page` to `Home`                                      |
| {Page=Home}                            | /Contact              | Matches and sets `Page` to `Contact`                                   |
| {controller}/{action}/{id?}            | /Products/List        | Maps to `Products` controller and `List`  action                       |
| {controller}/{action}/{id?}            | /Products/Details/123 |  Maps to `Products` controller and  `Details` action.  `id` set to 123 |
| {controller=Home}/{action=Index}/{id?} | /                     |  Maps to `Home` controller and `Index`  method; `id` is ignored.       |

Using a template is generally the simplest approach to routing. Constraints and defaults can also be specified outside the route template.

> [!TIP]
> Enable [Logging](xref:fundamentals/logging/index) to see how the built in routing implementations, such as `Route`, match requests.

## Reserved routing names

The following keywords are reserved names and can't be used as route names or parameters:

* `action`
* `area`
* `controller`
* `handler`
* `page`

## Route constraint reference

Route constraints execute when a `Route` has matched the syntax of the incoming URL and tokenized the URL path into route values. Route constraints generally inspect the route value associated via the route template and make a yes/no decision about whether or not the value is acceptable. Some route constraints use data outside the route value to consider whether the request can be routed. For example, the <xref:Microsoft.AspNetCore.Routing.Constraints.HttpMethodRouteConstraint> can accept or reject a request based on its HTTP verb.

> [!WARNING]
> Avoid using constraints for **input validation** because doing so means that invalid input results in a *404 - Not Found* response instead of a *400 - Bad Request* with an appropriate error message. Route constraints are used to **disambiguate** between similar routes, not to validate the inputs for a particular route.

The following table demonstrates some route constraints and their expected behavior.

| constraint | Example | Example Matches | Notes |
| ---------- | ------- | --------------- | ----- |
| `int` | `{id:int}` | `123456789`, `-123456789`  | Matches any integer |
| `bool` | `{active:bool}` | `true`, `FALSE` | Matches `true` or `false` (case-insensitive) |
| `datetime` | `{dob:datetime}` | `2016-12-31`, `2016-12-31 7:32pm`  | Matches a valid `DateTime` value (in the invariant culture - see warning) |
| `decimal` | `{price:decimal}` | `49.99`, `-1,000.01` | Matches a valid `decimal` value (in the invariant culture - see warning) |
| `double` | `{weight:double}` | `1.234`, `-1,001.01e8` | Matches a valid `double` value (in the invariant culture - see warning) |
| `float` | `{weight:float}` | `1.234`, `-1,001.01e8` | Matches a valid `float` value (in the invariant culture - see warning) |
| `guid` | `{id:guid}` | `CD2C1638-1638-72D5-1638-DEADBEEF1638`, `{CD2C1638-1638-72D5-1638-DEADBEEF1638}` | Matches a valid `Guid` value |
| `long` | `{ticks:long}` | `123456789`, `-123456789` | Matches a valid `long` value |
| `minlength(value)` | `{username:minlength(4)}` | `Rick` | String must be at least 4 characters |
| `maxlength(value)` | `{filename:maxlength(8)}` | `Richard` | String must be no more than 8 characters |
| `length(length)` | `{filename:length(12)}` | `somefile.txt` | String must be exactly 12 characters long |
| `length(min,max)` | `{filename:length(8,16)}` | `somefile.txt` | String must be at least 8 and no more than 16 characters long |
| `min(value)` | `{age:min(18)}` | `19` | Integer value must be at least 18 |
| `max(value)` | `{age:max(120)}` | `91` | Integer value must be no more than 120 |
| `range(min,max)` | `{age:range(18,120)}` | `91` | Integer value must be at least 18 but no more than 120 |
| `alpha` | `{name:alpha}` | `Rick` | String must consist of one or more alphabetical characters (`a`-`z`, case-insensitive) |
| `regex(expression)` | `{ssn:regex(^\\d{{3}}-\\d{{2}}-\\d{{4}}$)}` | `123-45-6789` | String must match the regular expression (see tips about defining a regular expression) |
| `required` | `{name:required}` | `Rick` |  Used to enforce that a non-parameter value is present during URL generation |

Multiple, colon-delimited constraints can be applied to a single parameter. For example, the following constraint restricts a parameter to an integer value of 1 or greater:

```csharp
[Route("users/{id:int:min(1)}")]
public User GetUserById(int id) { }
```

> [!WARNING]
> Route constraints that verify the URL and are converted to a CLR type (such as `int` or `DateTime`) always use the invariant culture. These constraints assume that the URL is non-localizable. The framework-provided route constraints don't modify the values stored in route values. All route values parsed from the URL are stored as strings. For example, the `float` constraint attempts to convert the route value to a float, but the converted value is used only to verify it can be converted to a float.

## Regular expressions

The ASP.NET Core framework adds `RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant` to the regular expression constructor. See <xref:System.Text.RegularExpressions.RegexOptions> for a description of these members.

Regular expressions use delimiters and tokens similar to those used by Routing and the C# language. Regular expression tokens must be escaped. To use the regular expression `^\d{3}-\d{2}-\d{4}$` in Routing, the expression must have the `\` characters typed in as `\\` in the C# source file to escape the `\` string escape character (unless using [verbatim string literals](/dotnet/csharp/language-reference/keywords/string). The `{`, `}`, `[`, and `]` characters must be escaped by doubling them to escape the Routing parameter delimiter characters. The table below shows a regular expression and the escaped version.

| Expression            | Escaped                        |
| --------------------- | ------------------------------ |
| `^\d{3}-\d{2}-\d{4}$` | `^\\d{{3}}-\\d{{2}}-\\d{{4}}$` |
| `^[a-z]{2}$`          | `^[[a-z]]{{2}}$`               |

Regular expressions used in routing often start with the `^` character (match starting position of the string) and end with the `$` character (match ending position of the string). The `^` and `$` characters ensure that the regular expression match the entire route parameter value. Without the `^` and `$` characters, the regular expression match any substring within the string, which is often undesirable. The table below shows some examples and explains why they match or fail to match.

| Expression   | String    | Match | Comment               |
| ------------ | --------- |  ---- |  -------------------- |
| `[a-z]{2}`   | hello     | Yes   | Substring matches     |
| `[a-z]{2}`   | 123abc456 | Yes   | Substring matches     |
| `[a-z]{2}`   | mz        | Yes   | Matches expression    |
| `[a-z]{2}`   | MZ        | Yes   | Not case sensitive    |
| `^[a-z]{2}$` |  hello    | No    | See `^` and `$` above |
| `^[a-z]{2}$` | 123abc456 | No    | See `^` and `$` above |

For more information on regular expression syntax, see [.NET Framework Regular Expressions](/dotnet/standard/base-types/regular-expression-language-quick-reference).

To constrain a parameter to a known set of possible values, use a regular expression. For example, `{action:regex(^(list|get|create)$)}` only matches the `action` route value to `list`, `get`, or `create`. If passed into the constraints dictionary, the string `^(list|get|create)$` is equivalent. Constraints that are passed in the constraints dictionary (not inline within a template) that don't match one of the known constraints are also treated as regular expressions.

::: moniker range=">= aspnetcore-2.2"

## Parameter transformer reference

Parameter transformers:

* Execute when generating a link for a `Route`.
* Implement `Microsoft.AspNetCore.Routing.IOutboundParameterTransformer`.
* Are configured using <xref:Microsoft.AspNetCore.Routing.RouteOptions.ConstraintMap>.
* Take the parameter's route value and transform it to a new string value.
* The transformed value is used in the generated link.

For example, a custom `slugify` parameter transformer in route pattern `blog\{article:slugify}` with `Url.Action(new { article = "MyTestArticle" })` generates `blog\my-test-article`.

Parameter transformers are also used by frameworks to transform the URI to which an endpoint resolves. For example, ASP.NET Core MVC uses parameter transformers to transform the route value used to match an `area`, `controller`, `action`, and `page`.

```csharp
routes.MapRoute(
    name: "default",
    template: "{controller=Home:slugify}/{action=Index:slugify}/{id?}");
```

With the preceding route, the action `SubscriptionManagementController.GetAll()` is matched with the URI `/subscription-management/get-all`. A parameter transformer doesn't change the route values used to generate a link. `Url.Action("GetAll", "SubscriptionManagement")` outputs `/subscription-management/get-all`.

ASP.NET Core provides API conventions for using a parameter transformers with generated routes:

* ASP.NET Core MVC has the `Microsoft.AspNetCore.Mvc.ApplicationModels.RouteTokenTransformerConvention` API convention. This convention applies a specified parameter transformer to all attribute routes in the app. The parameter transformer transforms attribute route tokens as they are replaced. For more information, see [Use a parameter transformer to customize token replacement](/aspnet/core/mvc/controllers/routing#use-a-parameter-transformer-to-customize-token-replacement).
* Razor pages has the `Microsoft.AspNetCore.Mvc.ApplicationModels.PageRouteTransformerConvention` API convention. This convention applies a specified parameter transformer to all automatically discovered Razor pages. The parameter transformer transforms the folder and file name segments of Razor page routes. For more information, see [Use a parameter transformer to customize page routes](/aspnet/core/razor-pages/razor-pages-conventions#use-a-parameter-transformer-to-customize-page-routes).

::: moniker-end

## URL generation reference

The following example shows how to generate a link to a route given a dictionary of route values and a <xref:Microsoft.AspNetCore.Routing.RouteCollection>.

::: moniker range=">= aspnetcore-2.0"

[!code-csharp[](routing/samples/2.x/RoutingSample/Startup.cs?name=snippet_Dictionary)]

::: moniker-end

::: moniker range="< aspnetcore-2.0"

[!code-csharp[](routing/samples/1.x/RoutingSample/Startup.cs?name=snippet_Dictionary)]

::: moniker-end

The `VirtualPath` generated at the end of the preceding sample is `/package/create/123`. The dictionary supplies the `operation` and `id` route values of the "Track Package Route" template, `package/{operation}/{id}`. For details, see the sample code in the [Use Routing Middleware](#use-routing-middleware) section or the [sample app](https://github.com/aspnet/Docs/tree/master/aspnetcore/fundamentals/routing/samples).

The second parameter to the `VirtualPathContext` constructor is a collection of *ambient values*. Ambient values provide convenience by limiting the number of values a developer must specify within a certain request context. The current route values of the current request are considered ambient values for link generation. In an ASP.NET Core MVC app if you are in the `About` action of the `HomeController`, you don't need to specify the controller route value to link to the `Index` action&mdash;the ambient value of `Home` is used.

Ambient values that don't match a parameter are ignored, and ambient values are also ignored when an explicitly provided value overrides it, going from left to right in the URL.

Values that are explicitly provided but which don't match anything are added to the query string. The following table shows the result when using the route template `{controller}/{action}/{id?}`.

| Ambient Values                | Explicit Values                   | Result                  |
| ----------------------------- | --------------------------------- | ----------------------- |
| controller="Home"             | action="About"                    | `/Home/About`           |
| controller="Home"             | controller="Order",action="About" | `/Order/About`          |
| controller="Home",color="Red" | action="About"                    | `/Home/About`           |
| controller="Home"             | action="About",color="Red"        | `/Home/About?color=Red` |

If a route has a default value that doesn't correspond to a parameter and that value is explicitly provided, it must match the default value:

```csharp
routes.MapRoute("blog_route", "blog/{*slug}",
    defaults: new { controller = "Blog", action = "ReadPost" });
```

Link generation only generates a link for this route when the matching values for controller and action are provided.

* Update routing.md
2018-10-15 17:47:55 -10:00
Dave Brock 65f9701d4a Updated help reference (#9048) 2018-10-15 17:01:02 -10:00
Andrew Stanton-Nurse da355e5085 Add note about WebSockets in IIS Express (#8621)
Fixes https://github.com/aspnet/Docs/issues/8618

We still need to call out that IIS Express does not support WebSockets in Windows 7, so we still need the section.

[Internal Review Link](https://review.docs.microsoft.com/en-us/aspnet/core/fundamentals/websockets?view=aspnetcore-2.1&branch=pr-en-us-8621)
2018-10-15 16:51:35 -10:00
Rick Anderson 0c33186a9a
Add version selector image for older versions (#9046)
* Add version selector image for older versions

* Add version selector image for older versions

* Add version selector image for older versions

* Add version selector image for older versions

* Add version selector image for older versions
2018-10-15 16:37:23 -10:00
Ryan Lilla f24311fd0d Update sort-filter-page.md with proper path names (#9039)
sections in the document where "Student/Index.cshtml" was used instead of the plural form "Students"
2018-10-15 14:37:09 -10:00
Cam Soper 2f96b5ba8c
Additional B2C tweaks (#8688)
* Whoops - didn't mean to merge that to this branch!

* minor updates

* minor updates

* Fixed issue #8552

* added a note on URL

* made Auth URL consistent with the portal (rather than Visual Studio)

* added a cool dagger for Luke

* phrasing

* formatting

* formatting - re-adding code fenced URLs

* Update azure-ad-b2c-webapi.md
2018-10-15 18:36:50 -05:00
Arun Kumar 8888ed323d fix typo (#9034) 2018-10-15 12:56:41 -10:00
Ryan Lilla affd31a7d9 Update crud.md with fixed typo (#9036)
found a typo in the FindAsync section where "they" was used instead of "that".
Currently: "Can have perf benefits in some situations, but that rarely happens for typical web apps."
2018-10-15 12:55:54 -10:00
Luke Latham 372ce59a2d
Update image (#9038) 2018-10-15 14:56:12 -05:00
Dave Brock fe3712ffc7 casing fixes (#9004)
Sorry for all the commits/reverts on the #8038 issue - I had my changes accidentally in the branch for another change and didn't want to leave it there.

Fixes #8038
2018-10-15 09:16:49 -10:00
James Newton-King 6ec334bc52 Add PageRouteTransformerConvention docs (#8969)
* Add PageRouteTransformerConvention docs

* Razor Pages conventions doc patch
2018-10-15 13:40:03 -05:00
Rick Anderson d0abcc683b Update filters.md (#8976)
Fixes #8958
2018-10-15 13:15:06 -05:00
Antoine Griffard 9693195d01 Typo in version-differences (#9022) 2018-10-15 12:24:50 -05:00
Luke Latham 13b70b1485
Repair code block links (#9030) 2018-10-15 11:56:23 -05:00
Antoine Griffard fc719ac941 Typo in streaming (#9021) 2018-10-15 11:41:39 -05:00
Antoine Griffard 1b16eded26 Typo in messagepackhubprotocol (#9020) 2018-10-15 11:40:54 -05:00
Mauricio de los Santos 8f3977e662 CC71738: Escaping components names to avoid broken format in translation pages (#8597)
Hello, @rick-anderson,
Localization team has reported source content issue that causes localized version to have broken/different format compared to en-us version.
Description: Some of the "folder names" inside \<\> are not displaying well in localized pages, and also those terms are not blocked for localization.

Please review and merge the proposed file change to fix to target versions. If you make related fix in another PR  then share your PR number so we can confirm and close this PR.
Many thanks in advance.
2018-10-13 12:58:39 -10:00
amadosoft 14f0c334b5 Update dependency-injection.md (#9008) 2018-10-13 10:27:16 -05:00
Luke Latham 7c9361bbd4
Enhance 'edge server' language (#9002) 2018-10-12 14:04:15 -05:00
Scott Addie 5b2f916cb4
Merge pull request #8985 from aspnet/tdykstra-patch-2
remove code formatting from headings
2018-10-12 12:11:05 -05:00
Luke Latham 417b677b9d
IIS Modules topic updates (+in-proc updates) (#8831) 2018-10-12 12:08:18 -05:00
Luke Latham e762fe8c57
Language enhancement to the Web Host topic (#8986) 2018-10-12 11:53:45 -05:00
Luke Latham 223f95bd10
Configuration enhancements (#8918) 2018-10-12 11:53:00 -05:00
Luke Latham 95edc2a774
Surface StatusCodes in Enforcing HTTPS topic (#8981) 2018-10-12 11:52:21 -05:00
Luke Latham 12e70e8875
Surface www redirect methods in URL Rewriting topic (#8982) 2018-10-12 11:49:09 -05:00
Luke Latham 4a38accc79
Clarify Azure App restart behavior of app settings (#8987) 2018-10-12 11:44:02 -05:00
Luke Latham 0a8f20ebdb
Update antiforgery cookie options (#8980) 2018-10-12 11:43:27 -05:00
Luke Latham 441cc474c0
Tag Helpers: Enhance cross-links and UE pass (#8964) 2018-10-12 11:17:59 -05:00
Pavel Voronin 3b5bb90d3b Update dependency-injection.md (#8996) 2018-10-12 07:52:37 -05:00
Dave Brock 7586ea1e1a Added EF Power Tools link (#8993) 2018-10-12 07:47:25 -05:00
Luke Latham f4b0be4375
Remark change in Windows Service topic (#8983) 2018-10-11 12:03:05 -05:00
Tom Dykstra e8be8e6ed2
remove code formatting from headings 2018-10-11 10:00:01 -07:00
Mark Pritchett 51b914aef2 Add launchSettings.json example to v2.0 -> v2.1 migration (#8865) 2018-10-11 06:17:57 -05:00
Kenn Jacobsen 235a9a2c89 Updates to the razor pages tutorial (#8953) 2018-10-11 06:17:07 -05:00
EthanR 2c7bc49ade Update index.md (#8975) 2018-10-11 06:11:33 -05:00
Dan Jacka caa86b9002 Typo fix: delete extraneous 'to' (#8971) 2018-10-11 06:10:51 -05:00
EthanR 7cc7b6a5b0 Update index.md (#8970) 2018-10-11 06:10:02 -05:00
EthanR c0c168784b Update benefits.md (#8968) 2018-10-11 06:06:15 -05:00
Rick Anderson 1b0872744d
Update web-api-vsc.md (#8965) 2018-10-10 17:33:32 -10:00
haidelber 97a199c5ee Fixed link description (#8962) 2018-10-10 11:23:34 -10:00
James Newton-King ee68f3c934 Add RouteTokenTransformerConvention documentation (#8942) 2018-10-10 15:45:45 -05:00
Rick Anderson e6a0c8c0a8
cache No Longer Evicts Under Memory Pressure (#8950)
* cache No Longer Evicts Under Memory Pressure

* Update memory.md
2018-10-10 09:46:53 -10:00
Mohammad Dehghan f514dc1a70 Remove duplicate word (#8952) 2018-10-10 08:05:26 -05:00
Luke Latham 5bffce9501 Clarification on Login form display scenarios (#8878) 2018-10-09 16:44:21 -10:00
Luke Latham dc26efa660 Enhance attribute table (#8943)
Fixes #8659 

[Internal Review Topic](https://review.docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-1.0&branch=pr-en-us-8943)

* Ranges added to the table.
* Add `processesPerApplication`.

Head-check on `requestTimeout` ... is the max timeout 360 hours (`360:00:00`)?
2018-10-09 16:16:17 -10:00
Luke Latham ba4b509279 Reconstitute installer flags (#8945)
Fixes #8748
2018-10-09 16:12:11 -10:00
Luke Latham 34291fb3fb Linux topic updates (#8944)
Fixes #8710 

1. Fix the `./<app_executable>` bit ... refer to the DLL.
1. Drop "mvc" from naming and go with "app."
1. Path to `/var/www/helloapp`.
2018-10-09 16:11:40 -10:00
Dave Brock 3923817574 Clarified compatibility version is in RP template by default (#8939)
Fixes #8932.
2018-10-09 11:09:09 -10:00
Luke Latham 8f74f445f9 Fix tutorial folder name (#8941)
Fixes #8937 

https://github.com/aspnet/Docs/tree/master/aspnetcore/data/ef-rp/intro/samples/cu21/Pages/Students
2018-10-09 10:47:33 -10:00
Luke Latham 477300456c Fix broken table (#8940)
Fixes #8938 

... and also escapes an underscore in a latter table cell.
2018-10-09 10:36:33 -10:00
Luke Latham d3b0a32154 In-process hosting model coverage (#8658)
Fixes #5599 
Fixes #5449 
Fixes #5403 


[Internal Review Topic (fundamentals/servers/ancm)](https://review.docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/aspnet-core-module?view=aspnetcore-1.0&branch=pr-en-us-8658)
[Internal Review Topic (fundamentals/servers/index)](https://review.docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/index?view=aspnetcore-1.0&branch=pr-en-us-8658)
[Internal Review Topic (host-and-deploy/ancm)](https://review.docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-1.0&branch=pr-en-us-8658)
[Internal Review Topic (host-and-deploy/iis/index)](https://review.docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-1.0&branch=pr-en-us-8658)
2018-10-09 09:20:34 -10:00
Kyle Burns 0192359c2a Update dependency-injection.md (#8611)
Elaborated on the recommendation to avoid Service Locator pattern
2018-10-09 09:18:08 -10:00
Hisham Bin Ateya d3b9269016 Use Microsoft.AspNetCore.App & CreateWebHostBuilder in web sockets sample (#8890)
* netcoreapp1.1 -> netcoreapp2.1

* Use Microsoft.AspNetCore.All meta package

* Use CreateWebHostBuilder

* Sample versioning

* Fix target framework

* Redo unnecessary changes

* Update packages version

* Implicit version for App package

* Fix the package name

* Versioning the code snippets

* WebSocketSample -> WebSocketsSample
2018-10-09 09:15:00 -10:00
Luke Latham 91a2e221a9 Update Kestrel topic sample to use ConfigureKestrel (#8914)
Fixes #8571
2018-10-09 09:07:18 -10:00
Tom Dykstra 9cf3e6ed15 Correct note about lazy loading (#8934)
Related to #8910 
[Internal review link](https://review.docs.microsoft.com/en-us/aspnet/core/data/ef-rp/read-related-data?branch=pr-en-us-8934&tabs=visual-studio)
2018-10-09 08:51:38 -10:00
Dave Brock d138521569 redundant spacing (#8930) 2018-10-09 11:43:33 -05:00
Dave Brock 07b06e9859 Added context around HEAD requests (#8928) 2018-10-09 11:41:44 -05:00
Dave Brock d2fc112258 Remove redundant "the" (#8931) 2018-10-09 11:39:36 -05:00
Hisham Bin Ateya 273a8485ac Fix localization resources links (#8927) 2018-10-09 10:59:08 -05:00
Dominik Raniszewski 123b4f49d3 Removing emphasis from the last paragraph (#8924) 2018-10-09 10:57:28 -05:00
Luke Latham fd3151cb2e Repair link (#8899)
Fixes #8898
2018-10-07 18:48:14 -10:00
Luke Latham 8e6dd4a7f4 Drop version from App package (#8881)
Addresses #8579 

I might be getting the hang of **_find and replace_** now. 😝

This doesn't touch a couple that ref 2.2.0. I'll tidy those up on https://github.com/aspnet/Docs/issues/8518 after 2.2 RTM.
2018-10-06 17:10:28 -10:00
Hisham Bin Ateya b0e9ee31c5 Use CreateWebHostBuilder in localization samples (#8882) 2018-10-06 17:09:16 -10:00
John Reese bdbde265b9 Resolve grammar issues (#8879) 2018-10-06 09:20:50 -05:00
Andrew Lock 834faab848 Clarifications around ConfigureAll and named options (#8869) 2018-10-05 17:56:24 -05:00
Hisham Bin Ateya 29c39626cd Fix localization sample namespace (#8860) 2018-10-05 12:50:39 -10:00
Luke Latham 97f9e2d403
Surface SCD for preview release to App Service (#8700) 2018-10-05 10:21:59 -05:00
Dave Brock 8ba0f07c5c
Update `IndexOption` to `Index`
The first `IndexOption` reference in the article is changed to `Index.` The second reference stays intact and is correct.
2018-10-04 20:40:36 -05:00
Rick Anderson f0bd9cedb1
Update choose-aspnet-framework.md (#8730)
* Update choose-aspnet-framework.md

* Update choose-aspnet-framework.md

* update choose between

* update choose between

* update choose between

* fix

* fix

* fix

* react to feedback

* Update choose-aspnet-framework.md
2018-10-04 15:25:35 -10:00
Rick Anderson 61f6c2735b
Update secure-data.md (#8856) 2018-10-04 15:21:58 -10:00
Tom Dykstra bf92bb67e2 Apply content model guidelines to Getting started tutorial (#8844)
Fixes #8778
2018-10-04 11:12:56 -10:00
Dave Brock 854e17807d Fix typo for #8286 (#8849)
Typo fix in code sample. 

Fixes #8286
2018-10-04 15:18:18 -05:00
Scott Addie b3eb47a2c5
Add missing period in title (#8851)
When creating a new PR, please do the following and delete this template text:

* Reference the issue number if there is one:

  Fixes #Issue_Number

  > The "Fixes #nnn" syntax in the PR description causes
  > GitHub to automatically close the issue when this PR is merged.
2018-10-04 15:08:01 -05:00
David Pine fee5f1800b Added details, examples and docs on Gulp v4 (#8843)
Fixes https://github.com/aspnet/Docs/issues/8827
Fixes https://github.com/aspnet/Docs/issues/7632

**Internal Review Pages**
* [Use Gulp](https://review.docs.microsoft.com/en-us/aspnet/core/client-side/using-gulp?view=aspnetcore-2.1&branch=pr-en-us-8843)
* [Bundle & minify](https://review.docs.microsoft.com/en-us/aspnet/core/client-side/bundling-and-minification?view=aspnetcore-2.1&branch=pr-en-us-8843)
2018-10-04 14:40:19 -05:00
Cecil Phillip 16af294128 Update messagepackhubprotocol.md (#8847)
Fixes #8821
PR for review. I just mirrored the note in the server section
@scottaddie @anurse
2018-10-04 14:29:33 -05:00
Jimmy Bogard 08c1ed8940 Corrected download link for Visual Studio (#8841) 2018-10-04 08:48:48 -05:00
Tom Dykstra 77471a229d
Apply content model guidelines to SignalR tutorial (#8817) 2018-10-03 13:04:56 -07:00
Tom Dykstra 055b3e55c8 Move Supported platforms out of Server concepts ToC (#8828) 2018-10-03 13:31:18 -05:00
Luke Latham 3b54380932
Add Brotli compression to the sample app (#8830) 2018-10-03 13:11:45 -05:00
Tom Dykstra e5670756e3 Change to code style where italics wasn't working (#8829)
Fixes #8823
2018-10-03 13:08:04 -05:00
Tom Dykstra fa5ebeba6f
Add available clients to SignalR supported platforms (#8729) 2018-10-03 09:34:37 -07:00
Scott Addie 3b6885b420
Correct the moniker range in WebSockets doc (#8809) 2018-10-03 08:36:25 -05:00
Luke Latham a4a449b4d9
Update instruction on picking up env var change (#8638) 2018-10-02 19:13:44 -05:00
Scott Addie f473fbf8c1
Fix Razor view snippet types (#8810) 2018-10-02 15:55:57 -05:00
Steve Patches 79e90ea1b7 mention HTML sanitization as deprecated approach (#8800)
Include some content from https://github.com/aspnet/Docs/issues/7962#issuecomment-410779470 that would be helpful to those who search for this topic.
2018-10-02 15:33:10 -05:00
Corey Ford c84d142185 fixed bug during socket.onclose (#8784)
* fixed bug during socket.onclose

* More JS cleanup
2018-10-02 14:17:25 -05:00
Bruno Garcia 344f16d38d Add Sentry, FOSS error monitoring tool (#8802) 2018-10-02 13:35:40 -05:00
Andrew Lock dcef25a7fb
Fixes for minor typos 2018-10-02 16:11:26 +01:00
Luke Latham a6b3666aff
Change code example in auth policy provider topic (#8799) 2018-10-02 08:49:50 -05:00
Tushar Koshti 1f017b785b Fixed typo mistake (#8791) 2018-10-02 08:25:53 -05:00
Dave Brock 5e190547ea Cosmetic changes for multiple files (#8764)
As I was preparing to rewrite a Razor Pages topic, I came across some minor cosmetic things while running through the Razor Pages tutorial. Since they were a bunch of little things, I thought I would group it into one request. As I'm fairly new at this, if you would like me to do it a different way in the future, just let me know.

Changes of note (all others were cosmetic and not worth discussing):
* `aspnetcore/includes/RP/razor-pages-start.md`: Moved description of `_ViewStart.cshtml` after `_ViewImports.cshtml` because that is how it is displayed in Visual Studio. Also added a short description of the `Privacy` page.
* `aspnetcore/tutorials/razor-pages/model/_static/conan.png`: Updated screenshot to contain `ReleaseDate` label and not `Release Date.` The display annotation is not discussed until later in the tutorial.
* `...als/razor-pages/razor-pages-start/sample/RazorPagesMovie21/Data/RazorPagesMovieContext.cs`: Removed unused usings and also removed the unnecessary FQNs. Same for the other code samples in this pull request.

Fixes #7252
2018-10-01 11:51:52 -10:00
José Maia 6619e940e4 Point to a central page explaining all signalr clients (#8782)
Fixes #8781
2018-10-01 15:21:55 -05:00
Scott Addie 56aa3bec94
2.1 update of Web API migration doc (#8717)
* 2.1 update of Web API migration doc

* Fix list formatting

* React to feedback
2018-10-01 14:55:27 -05:00
Haryz Izzudin 124e035f10 Content fixes for ASP.NET Core Getting Started page (#8779)
Fixes #8776.
2018-10-01 13:12:20 -05:00
Sebastiaan Dammann 682fdb36f8 Clarify middleware behavior with unknown file types, fixes #8602 (#8780) 2018-10-01 12:25:21 -05:00
obayit 28bcd1a21a correct a term (#8769)
The word implement can mislead the reader into thinking that he have to implement the interface,
an alternative is the word require, which is used when talking about dependency injection

When creating a new PR, please do the following and delete this template text:

* Reference the issue number if there is one:

  Fixes #Issue_Number

  > The "Fixes #nnn" syntax in the PR description causes
  > GitHub to automatically close the issue when this PR is merged.
2018-10-01 11:27:54 -05:00
Scott Addie e8966d448a
Remove link to retired doc (#8775) 2018-10-01 11:27:04 -05:00
Haryz Izzudin 57e9dcfa6b Fix code block showing backticks (#8772)
Indenting the code block with 4 spaces causes the Markdown parser to think that the lines with the backticks are also part of the code block, [as per the Markdown specifications](https://daringfireball.net/projects/markdown/syntax#precode). I reduced the indentation to 2 spaces to get around this problem.

Fixes #8563 

[Internal Review Page](https://review.docs.microsoft.com/en-us/aspnet/core/getting-started/?view=aspnetcore-2.1&branch=pr-en-us-8772)
2018-10-01 11:16:40 -05:00
Scott Addie c5a5a6c00a
Remove link to retired doc (#8773) 2018-10-01 11:04:46 -05:00
James Newton-King 5a87f3081f Round-tripping catch-all syntax + Parameter Transformers (#8759)
Addresses #8763

https://github.com/aspnet/Routing/issues/720

@rynowak
2018-10-01 10:53:34 -05:00
obayit cc96a62cd6 Remove UseBrowserLink (#8762) 2018-09-30 09:10:22 -05:00
Luke Latham d3db6fcd25
Fix highlighting in Background tasks code sample (#8761) 2018-09-29 19:21:21 -05:00
Rick Anderson 2e8dac2ca4
Update next.md (#8740)
* Update next.md

* Update next.md
2018-09-28 15:32:48 -10:00
Rick Anderson 2c94b676c9
Update index.md (#8731)
* Update index.md

* Update index.md
2018-09-28 15:32:21 -10:00
Dave Brock e2c39164a9 Added using for clarity (#8743)
Visual Studio does not recognize the query without using the `Microsoft.Linq` namespace, which isn't specified in the document.
2018-09-28 15:31:25 -10:00
Mark Rendle 911120b884 Add note on scaffolding all Identity UI pages from CLI (#8752) 2018-09-28 15:29:52 -10:00
Rick Anderson 4a96687c7d
Update metapackage.md (#8728)
Fixes #8312
Instructions copied from https://github.com/aspnet/Identity/issues/1870
2018-09-28 15:29:20 -10:00
Tom Dykstra 934fdbb87f Retire duplicate doc - pub to Azure using CLI (#8747)
Fixes #8723
2018-09-28 10:33:08 -10:00
Rick Anderson 20ce53d5cb
Update index.md (#8741) 2018-09-27 13:20:00 -10:00
Scott Addie 2a07c6f1df
Fix invalid Scaffold Identity link (#8739)
Fixes a link build warning introduced in https://github.com/aspnet/Docs/pull/8640.
2018-09-27 11:57:50 -05:00
Scott Addie 126bb378af
Make LibMan CLI destination path xplat (#8737)
Addresses the same problem that was fixed in https://github.com/aspnet/Docs/pull/8734.
2018-09-27 11:43:49 -05:00
Scott Addie 6ee808c991
2.1 updates to Identity PK data type doc (#8640)
* 2.1 updates to Identity PK data type doc

* Fix xref link

* Simplify doc

* Minor tweaks

* Verbiage tweaks

* Fix line highlighting

* Remove unused sample code

* Merge PK doc into larger customization doc

* Add missing property to ApplicationUser class

* Add redirect to retire PK doc

* Add missing file extension to redirect file

* Remove restriction on 2.1+

* Display lazy loading section for 2.1+

* Formatting changes

* Fix line highlighting

* Add property to ApplicationRole class

* Remove unnecessary override from ApplicationDbContext class

* Dedent code snippet

* Update customize-identity-model.md
2018-09-27 09:44:02 -05:00
Evan Ogas 6c1c25a490 Use forward slashes for destination path (#8734)
I don't have a way of testing this on Windows atm, but most of the other examples use forward slashes, so I assume this is correct on all platforms.  Backslashes fail on MacOS, creating a directory called "wwwrootlibsignalr".
2018-09-27 09:38:19 -05:00
Maxim Kornilov eb767b9464 Use the correct type as a parameter for the generic (#8724) 2018-09-26 20:54:56 -05:00
Dave Brock 8dd70094bd Fixing typo. (#8725) 2018-09-26 15:41:47 -10:00
Dave Brock cf5a94c7b2 Added corrected screenshot. (#8727) 2018-09-26 15:41:20 -10:00
Nate McMaster ba5171bda9 Add a section about storing data protection keys using the EF Core provider (#8328)
* Add a section about storing data protection keys using the EF Core provider

* UE pass and snippets

* Update key-storage-providers.md
2018-09-26 15:37:55 -10:00
Roy 8ef2cf1e97 Separate IFilterFactory from TypeFilterAttribute (#8720)
Add separate section using h3 title to separate out the IFilterFactory description from that of the TypeFilterAttribute when discussing dependency injection.
2018-09-26 15:38:44 -05:00
Keyur d0486b8ec6 Issue #8445 - Made the SMS 2FA note as a Warning (#8663)
* Added 'Scaleout differences' section

Saw this in one of the comments. So thought of adding it.

* Edits

* Issue #8445 - Made the SMS 2FA note as a Warning

Issue #8445 - Made the SMS 2FA note as a Warning
2018-09-26 10:14:48 -10:00
Luke Latham 36ce03f66f Add an additional resource to DI topic (#8642)
Fixes #8641 

... also @pakrym, can you say if this would have wide enough interest to become its own topic on the doc set?
2018-09-26 09:27:47 -10:00
Rick Anderson 1c08e30dd6
Version-less M.A.App (#8707)
* Version-less M.A.App

* Update metapackage-app.md
2018-09-26 09:21:36 -10:00
Nate McMaster db618cf993 Update the 2.1 migration doc to instruct users to remove the version on Microsoft.AspNetCore.App (#8715)
Reverts https://github.com/aspnet/Docs/pull/7543

See https://github.com/aspnet/Home/issues/3292#issuecomment-424146341 for context
2018-09-26 09:20:54 -10:00
Luke Latham 7c2f75b270
Add auth link to the Native Mobile Backend topic (#8719) 2018-09-26 14:09:44 -05:00
Rick Anderson c9bd31f145
Update validation.md (#8692)
* Update validation.md

Fixes #8687 
This link is much better as it doesn't involve SQL Server.

* Update validation.md
2018-09-25 15:53:56 -10:00
Rick Anderson 59e92baee9
Update details.md (#8693)
Also fixes  #8687
2018-09-25 15:53:36 -10:00
Luke Latham ae328f456d Distributed caching topic sample update (#8703)
Fixes #8514 

* Convert use of local time to UTC.
* I went for some naming upgrades and consistency.
  * I prefer not to post-fix types on variable names (i.e., "String" here).
  * I add "UTC" here and there tho to clarify what's held in vars and the cache key.
* Opened **Distributed cache topic UE pass** #8702 to do a pass on the topic later.
2018-09-25 14:38:05 -10:00
Luke Latham cfe4e9fa0d
Windows Service topic updates (#8705) 2018-09-25 17:32:32 -05:00
Tom Dykstra a26d3b82d2 update meta description (#8697)
@Rick-Anderson here's a suggestion for the meta description.
2018-09-25 12:17:54 -10:00
Luke Latham d4ccb7af34
Use MS architectural principles link in DI topic (#8701) 2018-09-25 15:52:24 -05:00
Rick Anderson cfb79e6975
Update razor-pages-start.md (#8691)
Keyword update.
2018-09-24 15:45:59 -10:00
Luke Latham 1da058f7dd
Improve Kestrel topic section support (#8689) 2018-09-24 17:29:10 -05:00
Luke Latham fdbee59807
Surface synchronous approach for view components (#8686) 2018-09-24 16:06:11 -05:00
Luke Latham 5b06b81ede
Surface the package in the Background Tasks topic (#8684) 2018-09-24 14:54:18 -05:00
Rick Anderson c181863998 Update bundling-and-minification.md (#8664)
Fixes #8614
@aureole82  please review.
2018-09-24 10:33:39 -05:00
Rick Anderson 25864d9dea Update app-secrets.md (#8662)
Need this for a doc in aspnet and it was too awful to copy.
2018-09-24 10:32:29 -05:00
Andrew Stanton-Nurse 55de66375a fix access token sample in SignalR auth document (#8680)
Fixes #8631 

The `AccessTokenFactory` expects a `Task<string>` so we need to wrap it in `Task.FromResult` in the sample (which is synchronous).
2018-09-24 10:24:26 -05:00
Cam Soper be93b1acb3
B2C doc fix (#8661)
* Whoops - didn't mean to merge that to this branch!

* minor updates

* minor updates

* Fixed issue #8552
2018-09-21 19:48:32 -05:00
Luke Latham 26286236f9
Response Compression updates (+Brotli) (#8560) 2018-09-21 17:12:21 -05:00
Luke Latham 4480bb1302
Note app pool restarts with the bundle installer (#8436) 2018-09-21 16:08:05 -05:00
Rico Suter 2e19966947 Fix snippets in NSwag tutorial (#8656)
Fixes the used snippets in the NSwag tutorial (currently the imports are missing and the configure snippet is used twice).
2018-09-21 12:16:54 -05:00
Rick Anderson a485e606d2
Update read-related-data.md 2018-09-20 15:23:33 -10:00
Rick Anderson c0ef0854b6
Update update-related-data.md (#8650) 2018-09-20 15:18:19 -10:00
Rick Anderson fca0e62fff
Update concurrency.md 2018-09-20 15:15:30 -10:00
Rick Anderson 116fa40551
Update individual.md (#8648)
Arg, now I need a link to win auth.
2018-09-20 14:56:30 -10:00
Rick Anderson 1d2f138aab
Update individual.md 2018-09-20 13:14:11 -10:00
Rick Anderson f5364daade
Update individual.md (#8645)
Fixes #8644

I need a fwlink to "No authentication" for VS.
2018-09-20 13:02:22 -10:00
Scott Addie 4f5fa6239d
Fix broken package.json file import (#8643)
Fixes an OPS build warning
2018-09-20 15:48:34 -05:00
Luke Latham ab66adea7c
Enhance KnownProxies/Networks content (#8634) 2018-09-20 14:01:02 -05:00
Luke Latham 8ec3fda3eb
Surface RuntimeIdentifiers (plural) in WS topic (#8637) 2018-09-20 13:57:21 -05:00
Rico Suter d6ab352542 Use API Explorer based NSwag generator and middlewares (#8572)
- Upgrade NSwag (samples) and use new API Explorer based generators (the reflection based generators are deprecated soon)
- Some text improvements
- Change "Open API" to "OpenAPI" (correct name)
- Use new Swagger UI 3 in samples

[Internal Review Page](https://review.docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-nswag?view=aspnetcore-2.1&branch=pr-en-us-8572&tabs=visual-studio%2Cvisual-studio-xml)
2018-09-20 11:32:52 -05:00
Luke Latham e5ed43144a
Remove webapp alias notice (#8629) 2018-09-19 23:03:52 -05:00
Rick Anderson 7705ae1e89
Fix SPA warning (#8595)
* Fix SPA warning

* rm download
2018-09-19 17:39:49 -10:00
Mikael Mengistu 5e95f82e20 SignalR Java Client preview1 -> preview2 (#8626)
Editing `Preview1 `to be `Preview2` in the Java client docs
2018-09-19 20:27:51 -05:00
Mikael Mengistu 4348c5837d Update to preview2 (#8593) 2018-09-19 17:41:24 -05:00
Rick Anderson ea8f1930c8
Update overview.md 2018-09-19 12:01:41 -10:00
Scott Addie 12764fb04b
Add SignalR Java API ref to ToC (#8619)
Link to the newly created ASP.NET Core SignalR Java API ref
2018-09-19 13:38:52 -05:00
Scott Addie 27883797d8
Remove quotes from bool value in appsettings.json (#8615)
Fixes https://github.com/aspnet/Docs/issues/8612
2018-09-19 09:53:48 -05:00
Luke Latham 480185ecd1
Surface System.Runtime.Caching content (#8550) 2018-09-18 21:36:25 -05:00
Rick Anderson 67c7b6cf6c
Update index.md (#8606) 2018-09-18 16:29:13 -10:00
Luke Latham 32cae1342e
Additional content on Cookie Policy Middleware (#8382) 2018-09-18 16:56:10 -05:00