ASPForums.Net RSS Feed additions to the content that appears on ASPForums.Net(c) 2019 All rights reserved.How to get logged in username after publishing in iis<p>Hi <a class="username" rel="danlpez07">danlpez07</a>,</p> <p>Refer the below code.</p> <p>you need to import the namespace <strong>System.Management </strong>by adding the reference in the project.<strong> </strong></p> <pre class="brush: csharp">ManagementObjectSearcher searcher = new ManagementObjectSearcher(&#34;SELECT UserName FROM Win32_ComputerSystem&#34;); ManagementObjectCollection collection = searcher.Get(); string username = (string)collection.Cast&lt;ManagementBaseObject&gt;().First()[&#34;UserName&#34;]; // Or string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;</pre> <p>Also refer the below link.</p> <p><a href="" target="_blank">Get username in c# that also works in IIS</a></p> <p>&nbsp;</p> <p>&nbsp;</p>, 21 Oct 2016 05:01:58 GMT