Interface IHttpService
Defines methods for working with HTTP-related services, such as retrieving request and application URLs, working with route URLs, and encoding URLs.
Namespace: DataWeb.Http
Assembly: DataWeb.Core.dll
Syntax
public interface IHttpService
Methods
GetAppUrl()
Gets the application URL based on the current HTTP context.
Declaration
string GetAppUrl()
Returns
| Type | Description |
|---|---|
| string | The application URL, or |
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
string GetPathAndQuery()
Returns
| Type | Description |
|---|---|
| string | The encoded path and query string of the current request, or |
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
string GetRemoteIpAddress()
Returns
| Type | Description |
|---|---|
| string | The remote IP address of the client making the request, or |
Remarks
This method uses the IHttpContextAccessor to retrieve the current HTTP context.
GetRequestMethod()
Gets the HTTP method of the current request.
Declaration
string GetRequestMethod()
Returns
| Type | Description |
|---|---|
| string | The HTTP method of the current request, or |
Remarks
This method uses the IHttpContextAccessor to retrieve the current HTTP context.
GetRequestUrl()
Gets the encoded URL of the current request.
Declaration
string GetRequestUrl()
Returns
| Type | Description |
|---|---|
| string | The encoded URL of the current request, or |
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
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 |
|
Returns
| Type | Description |
|---|---|
| string | The generated URL for the route, or |
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
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 WebUtility.UrlEncode(string) method to encode the URL string.