Skip to content

Commit

Permalink
Merge pull request #32244 from dotnet/main
Browse files Browse the repository at this point in the history
  • Loading branch information
guardrex authored Apr 4, 2024
2 parents b6ac003 + 5ac3be6 commit fb1fac7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/issue-processing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `### 😎 **March!** ***The gateway to spring!*** 🌞
body: `### 😎 **Welcome April!** ***Summertime is almost here!*** 🌞
A green dinosaur 🦖 will be along shortly to assist. *Stand-by ........*`
})
Expand Down
13 changes: 6 additions & 7 deletions aspnetcore/blazor/components/dynamiccomponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ In the following example, a Razor component renders a component based on the use

In the preceding example:

* Component names are used as the option values using the [`nameof` operator](/dotnet/csharp/language-reference/operators/nameof), which returns component names as constant strings.
* The namespace of the app is `BlazorSample`. ***Change the namespace to match your app's namespace.***
* An <xref:System.Collections.Generic.Dictionary%602> is used to manage components to be displayed.
* Names serve as the dictionary keys and are provided as selection options.
* Component types are stored as dictionary values using the [`typeof` operator](/dotnet/csharp/language-reference/operators/typeof).


## Pass parameters

Expand Down Expand Up @@ -197,7 +199,7 @@ The following `RocketLabWithWindowSeat` component (`RocketLabWithWindowSeat.razo
In the following example:

* Only the `RocketLabWithWindowSeat` component's parameter for a window seat (`WindowSeat`) receives the value of the **`Window Seat`** checkbox.
* The namespace of the app is `BlazorSample`. ***Change the namespace to match your app's namespace.***
* Component names are used as dictionary keys using the [`nameof` operator](/dotnet/csharp/language-reference/operators/nameof), which returns component names as constant strings.
* The dynamically-rendered components are shared components:
* Shown in this article section: `RocketLabWithWindowSeat` (`RocketLabWithWindowSeat.razor`)
* Components shown in the [Example](#example) section earlier in this article:
Expand Down Expand Up @@ -340,10 +342,7 @@ In the following parent component example, the `ShowDTMessage` method assigns a
The parent component passes the callback method, `ShowDTMessage` in the parameter dictionary:

* The `string` key is the callback method's name, `OnClickCallback`.
* The `object` value is created by <xref:Microsoft.AspNetCore.Components.EventCallbackFactory.Create%2A?displayProperty=nameWithType> for the parent callback method, `ShowDTMessage`. Note that the [`this` keyword](/dotnet/csharp/language-reference/keywords/this) isn't supported in C# fields, so a C# property is used for the parameter dictionary.

> [!IMPORTANT]
> For the following component, modify the code in the `OnDropdownChange` method. Change the namespace name of "`BlazorSample`" in the `Type.GetType()` argument to match your app's namespace.
* The `object` value is created by <xref:Microsoft.AspNetCore.Components.EventCallbackFactory.Create%2A?displayProperty=nameWithType> for the parent callback method, `ShowDTMessage`. Note that the [`this` keyword](/dotnet/csharp/language-reference/keywords/this) isn't supported in C# field initialization, so a C# property is used for the parameter dictionary.

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

Expand Down
2 changes: 1 addition & 1 deletion aspnetcore/blazor/fundamentals/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Obtain the app's environment in a component by injecting <xref:Microsoft.AspNetC
<h1>Environment example</h1>
<p>Environment: @HostEnvironment.Environment</p>
<p>Environment: @Env.Environment</p>
```

:::moniker range=">= aspnetcore-8.0"
Expand Down
60 changes: 8 additions & 52 deletions aspnetcore/grpc/test-tools.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
---
title: Test gRPC services with Postman or gRPCurl in ASP.NET Core
title: Test gRPC services with gRPCurl and gRPCui in ASP.NET Core
author: jamesnk
description: Learn how to test services with gRPC tools. Postman is an interactive web UI. gRPCurl a command-line tool for interacting with gRPC services. gRPCui is an interactive web UI.
description: Learn how to test services with gRPC tools. gRPCurl a command-line tool for interacting with gRPC services. gRPCui is an interactive web UI.
monikerRange: '>= aspnetcore-3.0'
ms.author: jamesnk
ms.date: 03/31/2022
ms.date: 04/03/2024
uid: grpc/test-tools
---
# Test gRPC services with Postman or gRPCurl in ASP.NET Core
# Test gRPC services with gRPCurl and gRPCui in ASP.NET Core

By [James Newton-King](https://twitter.com/jamesnk)
:::moniker range=">= aspnetcore-6.0"
Tooling is available for gRPC that allows developers to test services without building client apps:

* [Postman](https://www.postman.com/) is an API platform with an interactive UI for calling APIs. Postman can run in the browser or be downloaded and run locally. Postman supports calling gRPC services.
* [gRPCurl](https://github.com/fullstorydev/grpcurl) is an open-source command-line tool that provides interaction with gRPC services.
* [gRPCui](https://github.com/fullstorydev/grpcui) builds on top of gRPCurl and adds an open-source interactive web UI for gRPC.

This article discusses how to:

* Set up gRPC server reflection with a gRPC ASP.NET Core app.
* Interact with gRPC using test tools:
* Call gRPC services in Postman.
* Discover and test gRPC services with `grpcurl`.
* Interact with gRPC services via a browser using `grpcui`.

Expand All @@ -32,7 +30,7 @@ This article discusses how to:

Tooling must know the Protobuf contract of services before it can call them. There are two ways to do this:

* Set up [gRPC reflection](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md) on the server. Tools, such as gRPCurl and Postman, use reflection to automatically discover service contracts.
* Set up [gRPC reflection](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md) on the server. Tools, such as gRPCurl, use reflection to automatically discover service contracts.
* Add `.proto` files to the tool manually.

It's easier to use gRPC reflection. gRPC reflection adds a new gRPC service to the app that clients can call to discover services.
Expand All @@ -52,25 +50,6 @@ When gRPC reflection is set up:
* Client apps that support gRPC reflection can call the reflection service to discover services hosted by the server.
* gRPC services are still called from the client. Reflection only enables service discovery and doesn't bypass server-side security. Endpoints protected by [authentication and authorization](xref:grpc/authn-and-authz) require the caller to pass credentials for the endpoint to be called successfully.

## Postman

Postman is an API platform. It supports calling gRPC services with an interactive UI, among its many features.

To download and install Postman, see the [Download Postman page](https://www.postman.com/downloads/).

### Use Postman

Postman has an interactive UI for calling gRPC services. To call a gRPC service using Postman:

1. Select the **New** button and choose **gRPC Request**.
2. Enter the gRPC server's hostname and port in the server URL. For example, `localhost:5000`. Don't include the `http` or `https` scheme in the URL. If the server uses [Transport Layer Security (TLS)](https://tools.ietf.org/html/rfc5246), select the padlock next to the server URL to enable TLS in Postman.
3. Navigate to the **Service definition** section, then select server reflection or import the app's proto file. When complete, the dropdown list next to the server URL textbox has a list of gRPC methods available.
4. To call a gRPC method, select it in the dropdown, select **Generate Example Message**, then select **Invoke** to send the gRPC call to the server.

![gRPC in Postman](~/grpc/test-tools/static/postman.png)

A short video is also available that [walks through using Postman with gRPC](https://youtu.be/gfYGqMb81GQ).

## gRPCurl

gRPCurl is a command-line tool created by the gRPC community. Its features include:
Expand Down Expand Up @@ -155,7 +134,7 @@ $ grpcurl -d '{ "name": "World" }' localhost:<port> greet.Greeter/SayHello

## gRPCui

gRPCui is an interactive web UI for gRPC. gRPCui builds on top of gRPCurl. gRPCui offers a GUI for discovering and testing gRPC services, similar to HTTP tools such as Postman or Swagger UI.
gRPCui is an interactive web UI for gRPC. gRPCui builds on top of gRPCurl. gRPCui offers a GUI for discovering and testing gRPC services, similar to HTTP tools such as Swagger UI.

For information about downloading and installing `grpcui`, see the [gRPCui GitHub homepage](https://github.com/fullstorydev/grpcui#installation).

Expand All @@ -176,7 +155,6 @@ The tool launches a browser window with the interactive web UI. gRPC services ar

## Additional resources

* [Postman homepage](https://www.postman.com/)
* [gRPCurl GitHub homepage](https://github.com/fullstorydev/grpcurl)
* [gRPCui GitHub homepage](https://github.com/fullstorydev/grpcui)
* [`Grpc.AspNetCore.Server.Reflection`](https://www.nuget.org/packages/Grpc.AspNetCore.Server.Reflection)
Expand All @@ -188,15 +166,13 @@ The tool launches a browser window with the interactive web UI. gRPC services ar
:::moniker range=">= aspnetcore-3.0 < aspnetcore-6.0"
Tooling is available for gRPC that allows developers to test services without building client apps:

* [Postman](https://www.postman.com/) is an API platform with an interactive UI for calling APIs. Postman can run in the browser or be downloaded and run locally. Postman supports calling gRPC services.
* [gRPCurl](https://github.com/fullstorydev/grpcurl) is an open-source command-line tool that provides interaction with gRPC services.
* [gRPCui](https://github.com/fullstorydev/grpcui) builds on top of gRPCurl and adds an open-source interactive web UI for gRPC.

This article discusses how to:

* Set up gRPC server reflection with a gRPC ASP.NET Core app.
* Interact with gRPC using test tools:
* Call gRPC services in Postman.
* Discover and test gRPC services with `grpcurl`.
* Interact with gRPC services via a browser using `grpcui`.

Expand All @@ -207,7 +183,7 @@ This article discusses how to:

Tooling must know the Protobuf contract of services before it can call them. There are two ways to do this:

* Set up [gRPC reflection](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md) on the server. Tools, such as gRPCurl and Postman, use reflection to automatically discover service contracts.
* Set up [gRPC reflection](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md) on the server. Tools, such as gRPCurl, use reflection to automatically discover service contracts.
* Add `.proto` files to the tool manually.

It's easier to use gRPC reflection. gRPC reflection adds a new gRPC service to the app that clients can call to discover services.
Expand All @@ -227,25 +203,6 @@ When gRPC reflection is set up:
* Client apps that support gRPC reflection can call the reflection service to discover services hosted by the server.
* gRPC services are still called from the client. Reflection only enables service discovery and doesn't bypass server-side security. Endpoints protected by [authentication and authorization](xref:grpc/authn-and-authz) require the caller to pass credentials for the endpoint to be called successfully.

## Postman

Postman is an API platform. It supports calling gRPC services with an interactive UI, among its many features.

To download and install Postman, see the [Download Postman page](https://www.postman.com/downloads/).

### Use Postman

Postman has an interactive UI for calling gRPC services. To call a gRPC service using Postman:

1. Select the **New** button and choose **gRPC Request**.
2. Enter the gRPC server's hostname and port in the server URL. For example, `localhost:5000`. Don't include the `http` or `https` scheme in the URL. If the server uses [Transport Layer Security (TLS)](https://tools.ietf.org/html/rfc5246), select the padlock next to the server URL to enable TLS in Postman.
3. Navigate to the **Service definition** section, then select server reflection or import the app's proto file. When complete, the dropdown list next to the server URL textbox has a list of gRPC methods available.
4. To call a gRPC method, select it in the dropdown, select **Generate Example Message**, then select **Invoke** to send the gRPC call to the server.

![gRPC in Postman](~/grpc/test-tools/static/postman.png)

A short video is also available that [walks through using Postman with gRPC](https://youtu.be/gfYGqMb81GQ).

## gRPCurl

gRPCurl is a command-line tool created by the gRPC community. Its features include:
Expand Down Expand Up @@ -329,7 +286,7 @@ $ grpcurl -d '{ "name": "World" }' localhost:5001 greet.Greeter/SayHello

## gRPCui

gRPCui is an interactive web UI for gRPC. gRPCui builds on top of gRPCurl. gRPCui offers a GUI for discovering and testing gRPC services, similar to HTTP tools such as Postman or Swagger UI.
gRPCui is an interactive web UI for gRPC. gRPCui builds on top of gRPCurl. gRPCui offers a GUI for discovering and testing gRPC services, similar to HTTP tools such as Swagger UI.

For information about downloading and installing `grpcui`, see the [gRPCui GitHub homepage](https://github.com/fullstorydev/grpcui#installation).

Expand All @@ -348,7 +305,6 @@ The tool launches a browser window with the interactive web UI. gRPC services ar

## Additional resources

* [Postman homepage](https://www.postman.com/)
* [gRPCurl GitHub homepage](https://github.com/fullstorydev/grpcurl)
* [gRPCui GitHub homepage](https://github.com/fullstorydev/grpcui)
* [`Grpc.AspNetCore.Server.Reflection`](https://www.nuget.org/packages/Grpc.AspNetCore.Server.Reflection)
Expand Down
Binary file removed aspnetcore/grpc/test-tools/static/postman.png
Binary file not shown.
9 changes: 1 addition & 8 deletions aspnetcore/security/authentication/mfa.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,7 @@ build.Services.AddAuthentication(options =>
options.Scope.Add("profile");
options.Scope.Add("offline_access");
options.SaveTokens = true;
options.Events = new OpenIdConnectEvents
{
OnRedirectToIdentityProvider = context =>
{
context.ProtocolMessage.SetParameter("acr_values", "mfa");
return Task.FromResult(0);
}
};
options.AdditionalAuthorizationParameters.Add("acr_values", "mfa");
});
```

Expand Down

0 comments on commit fb1fac7

Please sign in to comment.