I’m not sure if this is by design or not but it seems a little odd to me. Or at best, the behavior is inconsistent across machines. I have a web application that will only display a button if the person who is on the site is a part of a certain AD group.
Here’s the code:
<td id="search-box">
@Using Html.BeginForm()
@Html.TextBox("SearchString", ViewBag.CurrentFilter)
@<input class="fancyButton" type="submit" value="Search" title="Job Name"/>
If Roles.IsUserInRole(User.Identity.Name, "mydomain\mygroup") Or Roles.IsUserInRole(User.Identity.Name, "mydomain\mygroup2") Then
@<input type="button" class="fancyButton" onclick="parent.location = '@Url.Action("Create")'" value="New"/>
End If
End Using
</td>
My id is a part of the group “mygroup”. So on my machine, when i open the website, it works fine. The button appears, and the Create record page appears correctly.
However, when another user that is a part of mygroup2 tries to view the app, although the button appears, when they click on it, they are prompted for a user ID and password.
I’m not sure why this is the case.
Does this behavior stay the same when you deploy to IIS on a separate server from your dev machine? It may have something more to do with the application pool identity than the authenticated user account. Deploying to a separate machine can help isolate the cause of the issue and identify the source of the authentication prompt.