Create a login system using config file using .net web aplication | YourSite

Create a login system using config file using .net web aplication

MS Dot NET 987 views

LoginPage.aspx page

This below page used for the Textbox and password field


 <h3 class="bg-primary text-white">Login Here</h3>
      <table class="table table-hover">
     <tr><td> <asp:TextBox ID="TextBox1" runat="server" placeholder="User Name"></asp:TextBox> </td></tr>
      <tr><td> <asp:TextBox ID="TextBox2" runat="server" placeholder="Password" TextMode="Password"></asp:TextBox> </td></tr>
       <tr><td> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> </td></tr>
      </table>

web config file


<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.6.1"/>
    <httpRuntime targetFramework="4.6.1"/>

<!-- THIS IS THE MAIN CODE WHICH IS MOST IMPORTANT -->
    <authentication mode="Forms">
      <forms defaultUrl="~/TravelDetailsInsert.aspx" loginUrl="~/LoginPage.aspx">
        <credentials passwordFormat="Clear">
          <user name="admin" password="admin"/>
          <user name="rumman" password="rumman"/>
        </credentials>
      </forms>
    </authentication>

<!-- END OF FOCUS HERE -->

  </system.web>

<!-- THE BELOW CODE IS IMPORTNT IF YOU WANT TO USE THE VALIDATION CONTROL -->
  <appSettings>
    <add key="ValidationSettings:UnObtrusiveValidationMode" value="None"/>    
  </appSettings>

<!--  THE BELOW CODE IS USED TO CONNECT WITH THE DATA BASE SQL SERVER-->
  <connectionStrings>
    <add name="constring" connectionString="Data Source = intvmsql01; Initial Catalog = DB02TEST01; User ID= pj02test01; password=tcstvm;"/>
  </connectionStrings>

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
    </compilers>
  </system.codedom>

</configuration>

file name: LoginPage.aspx.cs

The below using System.Web.Security; is important to execute the below code


using System.Web.Security;


protected void Button1_Click(object sender, EventArgs e)
        {

            if(FormsAuthentication.Authenticate(TextBox1.Text, TextBox2.Text))
            {
                FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);
            }
            else
            {
                Label3.Text = "Invalid Credentials entered.";
            }
            //if (TextBox1.Text == "admin" && TextBox2.Text == "password")
            //{
            //    Response.Redirect("TravelDetailsInsert.aspx");
            //    Label3.Text = Convert.ToString("Successfully Login");
            //} 
            //else
            //{
            //    Response.Write("<script> alert('User Name or Password is wrong') </script>");
            //    Label3.Text = Convert.ToString("UnSuccessfully Login");
            //}
        }

🚀 More Blogs You Might Like

Explore more articles and keep learning

WB Gram Panchayat Mock Test 2026 | Free Practice Test for Exam Preparation
youth-society
WB Gram Panchayat Mock Test 2026 | Free Practice Test for Exam Preparation

Practice free WB Gram Panchayat Mock Test online for 2026 exam preparation. Improve your speed, accuracy, and ...

👁 6 2026-06-14
Read More →
What is Bounce Rate in SEO? Complete Guide for Beginners
search-engine-optimization
What is Bounce Rate in SEO? Complete Guide for Beginners

Learn what bounce rate is in SEO, how it is calculated, why it matters, common causes of high bounce rates, an...

👁 29 2026-05-24
Read More →
Comprehensive Interviewer Guide - Detailed Article
skill
Comprehensive Interviewer Guide - Detailed Article

Learn how to conduct effective interviews with this comprehensive interviewer guide. Explore hiring strategies...

👁 44 2026-05-22
Read More →
Five Industry Shifts Reshaping the AI Ecosystem (2026 Trends)
skill
Five Industry Shifts Reshaping the AI Ecosystem (2026 Trends)

Five Industry Shifts Reshaping the AI Ecosystem (2026 Trends)...

👁 39 2026-05-19
Read More →