I'm trying to set up Windows authentication in my web app, but I cannot make it work. The app run in my computer (Windows 7 x64), I am in a domain network, and the app is running on the real IIS, not the Cassini web server.
What I have done so far:
- Enable basic authentication in IIS. (I have also tried to enable Windows Authentication)
- Web.config
<authentication mode="Windows"></authentication>
- I have tried with and without
<identity impersonate="true"/>
- I have put the
AuthorizeAttribute
within my controllers. - I have tried also the
<add key="autoFormsAuthentication" value="false"/>
fix for MVC3 Beta.
What I got:
I can open the page that has no AuthorizeAttribute
, I put a breakpoint and this is what I get in different properties related with authentication:
System.Security.Principal.WindowsIdentity.GetCurrent().Name
"IIS APPPOOL\\ASP.NET v4.0 DefaultAppPool"
Environment.UserDomainName
"IIS APPPOOL"
Environment.UserName
"ASP.NET v4.0 DefaultAppPool"
User.Identity.Name
""
Of course I cannot open any page with the [Authorize]
attribute.
The only thing I want is get the Windows use开发者_StackOverflowr name of the user that is accessing the web application. How should I do it?
It worked after reboot the computer. No idea what was wrong.
I had the same problem, it got resolved after I added the following tag in my <appSettings>
in my root web.config
.
<add key="enableSimpleMembership" value="false"/>
along with this
<add key="autoFormsAuthentication" value="false"/>
精彩评论