Donate

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:
 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:
Access Is Denied (User.Identity.Name) In ASP.NET MVC
The fix is to click on the MVC Project -> Navigate to Properties Window -> Change Windows Authentication from "Disabled" to "Enabled". See image below:
Access Is Denied (User.Identity.Name) In ASP.NET MVC
After setting that property, you can now see the user name and the program is running successfully.
Access Is Denied (User.Identity.Name) In ASP.NET MVC

Cheers! :)

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

Bootstrap Modal In ASP.NET MVC With CRUD Operations