Class RedirectModule
A module that redirects requests.
Inherited Members
Namespace: EmbedIO.Actions
Syntax
public class RedirectModule : WebModuleBase, IWebModuleImpl, IWebModule
Constructors
RedirectModule(String, String, HttpStatusCode)
Initializes a new instance of the RedirectModule class that will redirect all served requests.
Declaration
public RedirectModule(string baseRoute, string location, HttpStatusCode statusCode = null)
Parameters
Type | Name | Description |
---|---|---|
String | baseRoute | The base route. |
String | location | The redirect URL. |
HttpStatusCode | statusCode | The response status code; default is |
See Also
RedirectModule(String, String, Nullable<Func<IHttpContext, Boolean>>, HttpStatusCode)
Initializes a new instance of the RedirectModule class
that will redirect all requests for which the shouldRedirect
callback
returns true.
Declaration
public RedirectModule(string baseRoute, string location, Func<IHttpContext, bool>? shouldRedirect, HttpStatusCode statusCode = null)
Parameters
Type | Name | Description |
---|---|---|
String | baseRoute | The base route. |
String | location | The redirect URL. |
Nullable<Func<IHttpContext, Boolean>> | shouldRedirect | A callback function that returns true if a request must be redirected. |
HttpStatusCode | statusCode | The response status code; default is |
See Also
Properties
IsFinalHandler
Gets a value indicating whether processing of a request should stop after a module has handled it.
Declaration
public override bool IsFinalHandler { get; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
Remarks
If this property is true, a HTTP context's
SetHandled() method will be automatically called
immediately after after the
See Also
Location
Gets the redirect URL.
Declaration
public string Location { get; }
Property Value
Type | Description |
---|---|
String |
StatusCode
Gets the response status code.
Declaration
public HttpStatusCode StatusCode { get; }
Property Value
Type | Description |
---|---|
HttpStatusCode |
Methods
OnRequestAsync(IHttpContext)
Called to handle a request from a client.
Declaration
protected override Task OnRequestAsync(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttpContext | context | The context of the request being handled. |
Returns
Type | Description |
---|---|
Task | A |