running asp.net intranet application on localhost asking for authentication

Anjali Agarwal 1,386 Reputation points
2024-05-06T23:53:29.4066667+00:00

I have an intranet application written int ASP.net core, when I run this application on localhost, I get a pop window asking me to authenticate and once I enter my domain name\my username and password then it authenticates me and lets me run the application. Basically, I enter my Windows username and password and then I can see the application. Below is the screen of what I am getting:

User's image

this is what I tried:

  1. went to the folder where the application resides
  2. right click on it and click on the properties
  3. properties->Security tab and gave full control to myself. Below is the screenshot:

User's image

This is what I have in web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <security>
        <authentication>
          <anonymousAuthentication enabled="false" />
          <windowsAuthentication enabled="true" />
        </authentication>
      </security>
    </system.webServer>
  </location>
  <runtime>
 
  </runtime>
</configuration>

Since this is happening in localhost. Below is the screenshot of IIS express settings:

User's image

any help will be greatly appreciated.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,226 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,303 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,356 questions
{count} votes

2 answers

Sort by: Most helpful
  1. SurferOnWww 1,996 Reputation points
    2024-05-07T01:39:48.97+00:00

    Probably Basic Authentication is enabled and Anonymous Authentication is disabled. If you use IIS or IIS Express check the Authentication settings of the site.

    enter image description here


  2. Brando Zhang-MSFT 2,961 Reputation points Microsoft Vendor
    2024-05-07T07:05:38.0433333+00:00

    Hi @Anjali Agarwal,

    According to your screenshot, you could find you have enabled the windows authentication inside your application.

    You have enabled both using the web.config(IIS express) and your startup.cs.

    If you don't want to use windows authentication, you set the web.config as below and remove the related codes inside the startup.cs:

     
    <configuration> 
    <location path="." inheritInChildApplications="false"> 
    <system.webServer> 
    <security> 
    <authentication>
     <anonymousAuthentication enabled="true" /> 
    <windowsAuthentication enabled="false" /> 
    </authentication> 
    </security> 
    </system.webServer> 
    </location>
     <runtime>
     </runtime> 
    </configuration>
    

    Remove below line:

    services.AddAuthentication(NegotiateDefaults.AuthenticationScheme) .AddNegotiate();


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.