Unosquare
    Show / Hide Table of Contents

    Class RedirectModule

    A module that redirects requests.

    Inheritance
    Object
    WebModuleBase
    RedirectModule
    Implements
    IWebModuleImpl
    IWebModule
    Inherited Members
    WebModuleBase.Container
    WebModuleBase.IWebModuleImpl.SetContainer(IWebModuleContainer)
    WebModuleBase.BaseRoute
    WebModuleBase.OnUnhandledException
    WebModuleBase.OnHttpException
    WebModuleBase.LogSource
    WebModuleBase.Start(CancellationToken)
    WebModuleBase.MatchUrlPath(String)
    WebModuleBase.HandleRequestAsync(IHttpContext)
    WebModuleBase.OnStart(CancellationToken)
    WebModuleBase.SetContainer(IWebModuleContainer)
    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 302 - Found.

    See Also
    WebModuleBase(String)

    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 302 - Found.

    See Also
    WebModuleBase(String)

    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
    WebModuleBase.IsFinalHandler
    Remarks

    If this property is true, a HTTP context's SetHandled() method will be automatically called immediately after after the returned by HandleRequestAsync(IHttpContext) is completed. This will prevent the context from being passed further along to other modules.

    See Also
    IsHandled
    SetHandled()

    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 representing the ongoing operation.

    Overrides
    WebModuleBase.OnRequestAsync(IHttpContext)

    Implements

    IWebModuleImpl
    IWebModule

    See Also

    WebModuleBase

    Comments

    Back to top Copyright © 2017-2019 Unosquare