James Harpe
James Harpe

Reputation: 4345

.NET: User.IsInRole not working from within Visual Studio

I have a .NET MVC 4 application that uses Windows Authentication. I want to check whether the user is a member of a particular Active Directory group and if so, display an additional menu option:

            if(User.IsInRole("WellnessAdmins"))
            {
                <li>
                    <b>@Html.ActionLink("Admin","Admin","Home")</b>
                </li>
            }

When deployed to the server, this works fine; the Admin link is displayed. However, when I launch the application from Visual Studio, the Admin link is not displayed. My local computer and the server are on the same domain. Why this weird behavior?

Upvotes: 2

Views: 1356

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039538

If you are using IIS Express make sure that you have enabled Windows Authentication and disabled Anonymous Authentication in the properties of your project:

enter image description here

Upvotes: 2

Related Questions