Access Is Denied (User.Identity.Name) In ASP.NET MVC
Hi,
Given you have an ASP.NET MVC code below that will show the current user logged in a domain:
and when you run that project, you encountered an error such as below:

The fix is to click on the MVC Project -> Navigate to Properties Window -> Change Windows Authentication from "Disabled" to "Enabled". See image below:

After setting that property, you can now see the user name and the program is running successfully.
Cheers! :)
Given you have an ASP.NET MVC code below that will show the current user logged in a domain:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <div class="content-wrapper"> <div class="float-left"> <p class="site-title">@Html.ActionLink("your logo here", "Index", "Home")</p> </div> <div class="float-right"> <section id="login"> Hello, <span class="username">@User.Identity.Name</span>! </section> <nav> <ul id="menu"> <li>@Html.ActionLink("Home", "Index", "Home")</li> <li>@Html.ActionLink("About", "About", "Home")</li> <li>@Html.ActionLink("Contact", "Contact", "Home")</li> </ul> </nav> </div> </div> |
and when you run that project, you encountered an error such as below:
The fix is to click on the MVC Project -> Navigate to Properties Window -> Change Windows Authentication from "Disabled" to "Enabled". See image below:
After setting that property, you can now see the user name and the program is running successfully.
Cheers! :)
Comments
Post a Comment