Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 30, 2012 05:07 AM by Catherine Shan - MSFT
Nov 27, 2012 01:12 PM|LINK
When I debug my website locally using IIS Express + Windows Authentication, my authorization and custom Roles work correctly - my domain\username shows up by using Environment.UserDomainName and Environment.UserName, and my [Authorize(Roles = "MyCustomRole")]
works along with the User.IsInRole calls in Razor.
But when I deploy my website to a production IIS 7.5 instance, my domain\username shows up as NT Authority\Local System (or something like that, at home at the moment so I can't verify the exact text, but that's close). Also, none of my User.IsInRole checks
work, and my [Authorize] attributes do not work either. I've followed lots of setup docs regarding IIS 7.5 and Windows Authentication with ASP.NET, but it doesn't seem to be holding. Any ideas?
Nov 27, 2012 02:32 PM|LINK
If I set AnonymousAuthentication to Disabled, and change my Environment.UserDomainName \ Environment.UserName to User.Identity.Name, it seems to work.
I am noticing some oddities in my custom role authentication but that is a separate issue.
Nov 30, 2012 05:07 AM|LINK
Very glad to hear that you have resolved your issue and thank you for sharing your solution which will help others who meet the same issue. Welcome to Asp.net forum again.