IIS Form Authentication template

Denis Pasternak 581 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.

.NET Standard
.NET Standard
A formal specification of .NET APIs that are available on multiple .NET implementations.
483 questions
Internet Information Services
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,542 questions
No comments
{count} votes

Accepted answer
  1. SurferOnWww 636 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>
    
    No comments

2 additional answers

Sort by: Most helpful
  1. AgaveJoe 17,096 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


  2. Bruce (SqlWork.com) 28,031 Reputation points
    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.

    No comments