ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. 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="http://stackoverflow.com/questions/14072446/get-system-logged-in-username-in-c-sharp-that-also-works-in-iis" target="_blank">Get username in c# that also works in IIS</a></p> <p>&nbsp;</p> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/149375/How-to-get-logged-in-username-after-publishing-in-iis/https://www.aspforums.net:443/Threads/149375/How-to-get-logged-in-username-after-publishing-in-iis/Fri, 21 Oct 2016 05:01:58 GMT