Files
gpw_next/GPW.CORE.SMART/Controllers/InfoController.cs
T
Samuele Locatelli 1b88196574 Recupero IP OK
2023-01-12 12:54:28 +01:00

28 lines
891 B
C#

using Microsoft.AspNetCore.Mvc;
namespace GPW.CORE.Smart.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class InfoController : ControllerBase
{
/// <summary>
/// Controller epr recuperare l'IP del chiamante
///
/// rif: https://bartecki.me/blog/Blazor-serverside-get-remote-ip
/// https://stackoverflow.com/questions/57982444/how-do-i-get-client-ip-and-browser-info-in-blazor
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("ipaddress")]
public async Task<string> GetIpAddress()
{
var remoteIpAddress = this.HttpContext.Request.HttpContext.Connection.RemoteIpAddress;
await Task.Delay(1);
if (remoteIpAddress != null)
return remoteIpAddress.ToString();
return string.Empty;
}
}
}