User.Identity.Name blank in ASP.Net MVC
asp.net-mvc, iis
Solution
Sure is mate. You need to authenticate with the website. That's the name used for authentication.
You are authenticating, right?
It's not a setting, etc.
Click the LOG IN link, if you're using the stock standard ASP.NET MVC template (if my memory serves me right).
UPDATE (as the posted has added more info/comments)
So what you're after is Windows Authentication. A quick google search came up with this post. It's pretty helpful (though a bit old, but still relevant) .. check that out.
Found a better post with MVC code for Windows Authentication. Check that out instead.
Config setting that is important, is...
...
<system.web>
...
<authentication mode="Windows"/>
...
</system.web>
...
Problem
Exactly as per the title. Simply in my HomeController I have: ``` string Username = User.Identity.Name; ``` Why is this value always blank? Is there something special I have to place in the web.config to get this value to come through. I've tried on both the VS dev web server as well as on a windows server 2003 IIS server. It's got to be something simple, a server setting in IIS or something as the code is so simple and seems to be the correct way to reference this value. Thx a lot