How to get current windows user login name in MVC4 with .net Framework4.0
<p>I have been trying to the get the current windows user name, but finally NO.
Below are the ways which I have tried but could not get the user name, Am getting empty value</p>

<ol>
<li><p>STEP I have tried with </p>

<pre><code>string usr System.Web.HttpContext.Current.User.Identity.Name;
</code></pre>

<p>Got empty value</p></li>
<li><p>STEP Checked in my local ISS under Security and Enabled Windows Authentication</p></li>
<li><p>STEP in my project I have checked the radio button to use "Use Visual Studio" Development Server</p></li>
<li><p>STEP in my <code>web.config</code> file I have selected Form=Windows </p>

<pre><code>&lt;authentication mode="Windows"&gt;
    &lt;forms loginUrl="~/Account/Login" timeout="2880" /&gt;
&lt;/authentication&gt;
</code></pre></li>
<li><p>STEP: I have also tried with authorization</p>

<pre><code>&lt;authentication mode="Windows" &gt;
    &lt;forms loginUrl="~/Account/Login" timeout="2880" /&gt;
&lt;/authentication&gt;
&lt;authorization&gt;
    &lt;deny users="?"/&gt;
&lt;/authorization&gt;
</code></pre></li>
<li><p>STEP: I hosted in my development server and made a check of Anonymous Authenticate = Disable and Windows Authentication = Enable</p></li>
<li><p>STEP: Authorize (I have used this on top of controller)</p>

<pre><code>string str = System.Web.HttpContext.Current.User.Identity.Name 
</code></pre>

<p>but got empty value</p></li>
</ol>

<p>I have tried all these way to get the current user name but am getting empty value. I am trying to get it under controller. Is there a way to get this? Please advice.</p>