28 lines
891 B
C#
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;
|
|
}
|
|
}
|
|
}
|