0

I have an application that is exclusively for the people within our network. What I need to do is to get the Username, IP, and hostname of the people who visit the site. With this:

string userName = Environment.UserDomainName;
        string hostName = Dns.GetHostName();
        IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(hostName);
        IPAddress[] addr = ipEntry.AddressList;
        string ip = addr[1].ToString();

I was able to get the user information but NOT of the visitor of the site. What im getting is IIS APPPOOL as the username and other data is related to IIS or the server where my application is hosted. I dont want any login within the site. I just need it seamlessly.

What are the actions I need to put this altogether ?

OneLazy
  • 499
  • 4
  • 16
  • Possible duplicate of [How to get current user who's accessing an ASP.NET application?](https://stackoverflow.com/questions/5417125/how-to-get-current-user-whos-accessing-an-asp-net-application) And: https://stackoverflow.com/questions/2577496/how-can-i-get-the-clients-ip-address-in-asp-net-mvc – aquinas May 23 '18 at 02:33
  • You are looking at the domain user that the site is running under, as you have found. What you need to do is look at the authenticated user. What type of authentication are you using? – David L May 23 '18 at 02:34
  • @DavidL I am not using any authentication yet. I am not sure how to set this up as well. – OneLazy May 23 '18 at 02:42
  • If you have no authentication (which is another way of saying no way to identify who is using your application) then how do you expect to identify who is using your application? – David L May 23 '18 at 02:44
  • Now I enabled windows authentication in IIS, also in my web config. but it seems not to work afterall – OneLazy May 23 '18 at 03:11
  • im getting "Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance." – OneLazy May 23 '18 at 03:12

0 Answers0