IIS Form Authentication template

Mountain Pond 1,576 Reputation points
2022-06-04T06:54:45.36+00:00

Hi,
perhaps someone will share the source code of the authentication web page. Perhaps there is a standard page?

There is an iis resource where basic authentication is used. After opening the page, a window for entering a name and password appears. But I would like to have a page where the user will be prompted to enter credentials.

Thank you.

Windows development Internet Information Services
Developer technologies ASP.NET ASP.NET Core
Developer technologies .NET Other
0 comments No comments
{count} votes

Accepted answer
  1. SurferOnWww 4,631 Reputation points
    2022-06-05T01:08:06.437+00:00

    If you can use the Visual Studio 2010, its template for ASP.NET Web Application will be able to create the project with the Forms Authentication. The auto-generated web.config file includes the settings to make the Forms Authentication available, as follows:

    <?xml version="1.0"?>
    
    <!--
      To configure ASP.NET application refer to 
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    
    <configuration>
      <connectionStrings>
        <add name="ApplicationServices"
             connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;
                               AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
             providerName="System.Data.SqlClient" />
      </connectionStrings>
    
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
    
        <authentication mode="Forms">
          <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
        </authentication>
    
        <membership>
          <providers>
            <clear/>
            <add name="AspNetSqlMembershipProvider" 
                 type="System.Web.Security.SqlMembershipProvider" 
                 connectionStringName="ApplicationServices"
                 enablePasswordRetrieval="false" 
                 enablePasswordReset="true" 
                 requiresQuestionAndAnswer="false" 
                 requiresUniqueEmail="false"
                 maxInvalidPasswordAttempts="5" 
                 minRequiredPasswordLength="6" 
                 minRequiredNonalphanumericCharacters="0" 
                 passwordAttemptWindow="10"
                 applicationName="/" />
          </providers>
        </membership>
    
        <profile>
          <providers>
            <clear/>
            <add name="AspNetSqlProfileProvider" 
                 type="System.Web.Profile.SqlProfileProvider" 
                 connectionStringName="ApplicationServices" 
                 applicationName="/"/>
          </providers>
        </profile>
    
        <roleManager enabled="false">
          <providers>
            <clear/>
            <add name="AspNetSqlRoleProvider" 
                 type="System.Web.Security.SqlRoleProvider" 
                 connectionStringName="ApplicationServices" 
                 applicationName="/" />
            <add name="AspNetWindowsTokenRoleProvider" 
                 type="System.Web.Security.WindowsTokenRoleProvider" 
                 applicationName="/" />
          </providers>
        </roleManager>
    
      </system.web>
    
      <system.webServer>
         <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
    </configuration>
    
    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. AgaveJoe 30,126 Reputation points
    2022-06-04T11:59:22.103+00:00

    ASP.NET Core use the authentication cookie middleware not Forms Authentication. Forms Authentication is a feature in .NET framework.

    See the following reference documentation which has sample code.
    Use cookie authentication without ASP.NET Core Identity

    1 person found this answer helpful.

  2. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-06-04T15:18:50.203+00:00

    Basic authentication is done by IIS and the browser, no application code is required. To have a login page you need to write application code. Typically cookie authentication as suggested in the above answer.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.