I’m actually following a tutorial about creating a login page etc for a web project. It all works and now I am working on layout. I have added an image tag to my login page, as simple as , the src is correct, the image is definitely there, but the image will not show up on the page, why??
The image works if I copy and paste the tag into one of the other pages in the project, but not the Login.aspx page!
I must be suffering from ‘lack of brains friday’ syndrome because this has got me stumped! Maybe I should see if I can get a half-day and go home…
Thanks.
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="sm_development.Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Login Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<img src="images/redflag.png" style="width: 1024px; height: 893px; border: none;
padding: 0px;" alt="alt" />
username<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
password<br />
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox>
<br />
<asp:Button ID="Button1" OnClick="Button1_Click" runat="server" Text="Submit" />
</div>
</form>
</body>
</html>
So, I added the following to my web.config file under the file, which according to the docs should grant anybody access to the images folder whether they have logged in or not:
<!-- This section gives the unauthenticated user access to all of the files that are stored in the images folder. -->
<location path="images">
<system.web>
<authorization>
<allow users ="*" />
</authorization>
</system.web>
</location>
I’m actually going to change this in future and reorganize it so that only those images required by pages such as the login etc. are available to all and the rest are protected. Interesting lesson for today!
Thanks for all the replies.
Verify that the image is not in a location that is locked down. You say you can get it to work on other pages, but do you need to login to get to those pages? If so then the fact that you logged in is giving those pages the ability to show the image. When your at the login screen, you are not logged in of course, so the images directory might be secured and therefore not viewable.
Your web.config has probably secured everything from the root so your ‘images’ directory might require you to be logged in to have access to it.
Have you login.aspx in the root and move all your secured code into a sub directory. Make sure you setup your web.config files correctly.