How To Add Image In Login Page In Asp Net

How To Articles

In this article, I will guide you on how to add an image to the login page in ASP.NET. As a web developer, I understand the importance of creating visually appealing and user-friendly login pages. By adding an image, you can enhance the overall look and feel of your login page and create a more engaging user experience.

Before we begin, make sure you have a basic understanding of ASP.NET and Visual Studio. If you haven’t already, you can download and install Visual Studio from the official Microsoft website.

Step 1: Creating a New ASP.NET Web Application

The first step is to create a new ASP.NET web application project in Visual Studio. To do this, follow these steps:

  1. Open Visual Studio and click on “Create a new project.”
  2. Select “ASP.NET Web Application” from the available templates.
  3. Choose a name and location for your project, and click “Create.”
  4. In the next window, select “Web Forms” as the project template.
  5. Click “OK” to create the project.

Step 2: Adding an Image to the Login Page

Now that we have our ASP.NET web application project set up, let’s add an image to the login page. Follow these steps:

  1. Locate the “Login.aspx” file in the Solution Explorer panel.
  2. Double-click on “Login.aspx” to open it in the Visual Studio designer.
  3. In the designer view, find the <asp:Content> tag and add the following code inside it:

<div class="login-image">
<img src="~/Images/login-image.jpg" alt="Login Image" />

Make sure to replace “login-image.jpg” with the path and filename of your desired image.

Step 3: Styling the Image

Now that we have added the image, let’s apply some styling to make it visually appealing. To do this, we will use CSS. Follow these steps:

  1. Open the “Site.css” file in the Solution Explorer.
  2. Add the following CSS code at the end of the file:

.login-image {
margin: 20px auto;
text-align: center;

.login-image img {
width: 200px;
height: auto;

Feel free to adjust the CSS properties to suit your preferences.

Step 4: Testing the Login Page

Now that we have added the image and applied the necessary styling, it’s time to test our login page. Follow these steps:

  1. Press Ctrl + F5 to run the application.
  2. Navigate to the login page by appending /Login.aspx to the URL.
  3. You should see the login page with the image displayed.

Congratulations! You have successfully added an image to the login page in ASP.NET.


Adding an image to the login page in ASP.NET can greatly enhance the overall visual appeal and user experience of your application. By following the steps outlined in this article, you can easily incorporate this feature into your own projects. Remember to choose an image that is relevant and aligns with the overall theme of your application. Happy coding!