共用方式為


TypedResults.ServerSentEvents Method

Definition

Overloads

ServerSentEvents(IAsyncEnumerable<String>, String)

Produces a ServerSentEventsResult<T> response.

public static Microsoft.AspNetCore.Http.HttpResults.ServerSentEventsResult<string> ServerSentEvents(System.Collections.Generic.IAsyncEnumerable<string> values, string? eventType = default);
static member ServerSentEvents : System.Collections.Generic.IAsyncEnumerable<string> * string -> Microsoft.AspNetCore.Http.HttpResults.ServerSentEventsResult<string>
Public Shared Function ServerSentEvents (values As IAsyncEnumerable(Of String), Optional eventType As String = Nothing) As ServerSentEventsResult(Of String)

Parameters

values
IAsyncEnumerable<String>

The values to be included in the HTTP response body.

eventType
String

The event type to be included in the HTTP response body.

Returns

The created ServerSentEventsResult<T> for the response.

Remarks

Strings serialized by this result type are serialized as raw strings without any additional formatting.

Applies to

ServerSentEvents<T>(IAsyncEnumerable<SseItem<T>>)

Produces a ServerSentEventsResult<T> response.

public static Microsoft.AspNetCore.Http.HttpResults.ServerSentEventsResult<T> ServerSentEvents<T>(System.Collections.Generic.IAsyncEnumerable<System.Net.ServerSentEvents.SseItem<T>> values);
static member ServerSentEvents : System.Collections.Generic.IAsyncEnumerable<System.Net.ServerSentEvents.SseItem<'T>> -> Microsoft.AspNetCore.Http.HttpResults.ServerSentEventsResult<'T>
Public Shared Function ServerSentEvents(Of T) (values As IAsyncEnumerable(Of SseItem(Of T))) As ServerSentEventsResult(Of T)

Type Parameters

T

The type of object that will be serialized to the response body.

Parameters

values
IAsyncEnumerable<SseItem<T>>

The values to be included in the HTTP response body.

Returns

The created ServerSentEventsResult<T> for the response.

Remarks

Strings serialized by this result type are serialized as raw strings without any additional formatting. Other types are serialized using the configured JSON serializer options.

Applies to

ServerSentEvents<T>(IAsyncEnumerable<T>, String)

Produces a ServerSentEventsResult<T> response.

public static Microsoft.AspNetCore.Http.HttpResults.ServerSentEventsResult<T> ServerSentEvents<T>(System.Collections.Generic.IAsyncEnumerable<T> values, string? eventType = default);
static member ServerSentEvents : System.Collections.Generic.IAsyncEnumerable<'T> * string -> Microsoft.AspNetCore.Http.HttpResults.ServerSentEventsResult<'T>
Public Shared Function ServerSentEvents(Of T) (values As IAsyncEnumerable(Of T), Optional eventType As String = Nothing) As ServerSentEventsResult(Of T)

Type Parameters

T

The type of object that will be serialized to the response body.

Parameters

values
IAsyncEnumerable<T>

The values to be included in the HTTP response body.

eventType
String

The event type to be included in the HTTP response body.

Returns

The created ServerSentEventsResult<T> for the response.

Remarks

Strings serialized by this result type are serialized as raw strings without any additional formatting. Other types are serialized using the configured JSON serializer options.

Applies to