-
Notifications
You must be signed in to change notification settings - Fork 0
easyextensionsaspnetcore HttpRequestExtensions
BigMakCode edited this page Aug 5, 2024
·
1 revision
HttpRequest extensions.
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph EasyExtensions.AspNetCore
EasyExtensions.AspNetCore.HttpRequestExtensions[[HttpRequestExtensions]]
end
Returns | Name |
---|---|
string |
GetRemoteAddress (HttpRequest request)Get remote host IP address using proxy "X-Real-IP", "CF-Connecting-IP", "X-Forwarded-For" headers, or connection remote IP address. |
bool |
TooManyRequests (... )Check if there are too many requests from the same IP address, using in-memory cache. |
HttpRequest extensions.
public static string GetRemoteAddress(HttpRequest request)
Type | Name | Description |
---|---|---|
HttpRequest |
request |
Get remote host IP address using proxy "X-Real-IP", "CF-Connecting-IP", "X-Forwarded-For" headers, or connection remote IP address.
IP address, or "Unknown" by default.
public static bool TooManyRequests(HttpRequest request, int atTimeSeconds, int maxRepeats)
Type | Name | Description |
---|---|---|
HttpRequest |
request | HTTP request. |
int |
atTimeSeconds | Time period to check, default is 60 seconds. |
int |
maxRepeats | Maximum number of requests for the specified time period, default is 1. |
Check if there are too many requests from the same IP address, using in-memory cache.
True if there are too many requests, otherwise false.
public static bool TooManyRequests(HttpRequest request, TimeSpan atTime, int maxRepeats)
Type | Name | Description |
---|---|---|
HttpRequest |
request | HTTP request. |
TimeSpan |
atTime | Time period to check, default is 60 seconds. |
int |
maxRepeats | Maximum number of requests for the specified time period, default is 1. |
Check if there are too many requests from the same IP address, using in-memory cache.
True if there are too many requests, otherwise false.
public static bool TooManyRequests(string ip, TimeSpan atTime, int maxRepeats)
Type | Name | Description |
---|---|---|
string |
ip | IP address. |
TimeSpan |
atTime | Time period to check. |
int |
maxRepeats | Maximum number of requests for the specified time period, default is 1. |
Check if there are too many requests from the same IP address, using in-memory cache.
True if there are too many requests, otherwise false.
Generated with ModularDoc