Skip to content

Instantly share code, notes, and snippets.

@sfmskywalker
Created June 25, 2018 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfmskywalker/ebd263db75b586263bd5bbd68d6ea2cd to your computer and use it in GitHub Desktop.
Save sfmskywalker/ebd263db75b586263bd5bbd68d6ea2cd to your computer and use it in GitHub Desktop.
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace MultiTenantApp.Features.RemoteIp
{
public class RemoteIpMessageProvider : IMessageProvider
{
private readonly IHttpContextAccessor _httpContextAccessor;
public RemoteIpMessageProvider(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public Task<string> GetMessageAsync()
{
var remoteIpAddress = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress;
return Task.FromResult($"Your IP Address: {remoteIpAddress}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment