DataWeb
Search Results for

    Show / Hide Table of Contents

    Class HttpService

    An implementation of the IHttpService interface for working with HTTP-related tasks.

    Inheritance
    object
    HttpService
    Implements
    IHttpService
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: DataWeb.Http
    Assembly: DataWeb.Core.dll
    Syntax
    public class HttpService : IHttpService
    Remarks

    Initializes a new instance of the HttpService class.

    Constructors

    HttpService(IHttpContextAccessor, LinkGenerator)

    An implementation of the IHttpService interface for working with HTTP-related tasks.

    Declaration
    public HttpService(IHttpContextAccessor httpContextAccessor, LinkGenerator linkGenerator)
    Parameters
    Type Name Description
    IHttpContextAccessor httpContextAccessor

    The HTTP context accessor.

    LinkGenerator linkGenerator

    The link generator.

    Remarks

    Initializes a new instance of the HttpService class.

    Methods

    GetAppUrl()

    Gets the application URL based on the current HTTP context.

    Declaration
    public string GetAppUrl()
    Returns
    Type Description
    string

    The application URL, or null if the HTTP context is not available.

    Remarks

    This method uses the IHttpContextAccessor to retrieve the current HTTP context.

    GetPathAndQuery()

    Gets the encoded path and query string of the current request.

    Declaration
    public string GetPathAndQuery()
    Returns
    Type Description
    string

    The encoded path and query string of the current request, or null if the HTTP context is not available.

    Remarks

    This method uses the IHttpContextAccessor to retrieve the current HTTP context.

    GetRemoteIpAddress()

    Gets the remote IP address of the client making the request.

    Declaration
    public string GetRemoteIpAddress()
    Returns
    Type Description
    string

    The remote IP address of the client making the request, or null if the HTTP context is not available or the remote IP address is not known.

    Remarks

    This method uses the IHttpContextAccessor to retrieve the current HTTP context.

    GetRequestMethod()

    Gets the HTTP method of the current request.

    Declaration
    public string GetRequestMethod()
    Returns
    Type Description
    string

    The HTTP method of the current request, or null if the HTTP context is not available.

    Remarks

    This method uses the IHttpContextAccessor to retrieve the current HTTP context.

    GetRequestUrl()

    Gets the encoded URL of the current request.

    Declaration
    public string GetRequestUrl()
    Returns
    Type Description
    string

    The encoded URL of the current request, or null if the HTTP context is not available.

    Remarks

    This method uses the IHttpContextAccessor to retrieve the current HTTP context.

    GetRouteUrl(string, object, bool)

    Gets the URL for a route with the specified name and parameters.

    Declaration
    public string GetRouteUrl(string routeName, object parameters, bool isAbsoluteUrl)
    Parameters
    Type Name Description
    string routeName

    The name of the route to generate the URL for.

    object parameters

    An object that contains the parameters for the route.

    bool isAbsoluteUrl

    true to return an absolute URL; false to return a relative URL.

    Returns
    Type Description
    string

    The generated URL for the route, or null if the routeName is not found or the HTTP context is not available.

    Remarks

    This method uses the IHttpContextAccessor and LinkGenerator to generate the URL for the route.

    UrlEncode(string)

    Encodes the specified URL string using URL encoding rules.

    Declaration
    public string UrlEncode(string url)
    Parameters
    Type Name Description
    string url

    The URL string to encode.

    Returns
    Type Description
    string

    The encoded URL string.

    Remarks

    This method uses the UrlEncode(string) method to encode the URL string.

    Implements

    IHttpService
    In this article
    Back to top Generated by DocFX