How to show images in the Logon Page when Forms Authentication is

Discussion in 'ASP .Net Security' started by GregoryJ, May 7, 2009.

  1. GregoryJ

    GregoryJ Guest

    I have a Logon.aspx web page in my root folder of my web-site. I'm using
    Forms Authentications to authenticate my users. The Forms Authentication
    aspect works fine. The problem I'm having is that my Logon Page needs to
    display some images that are in my /Image folder.

    When the Logon.aspx page loads all images on my Logon.aspx page do not show
    up, even though the URL Links are correct. In design more everything looks
    fine. In fact, if I turn off Forms Authentication the images appear.

    I'm assuming the image files are not accessible because they don't have
    access to them.

    How can I get my logon form to show the images before the user has logged on?

    GregoryJ, May 7, 2009
    1. Advertisements

  2. GregoryJ

    EagleRed Guest

    What folder/directory contains your logon page? How are you referencing your
    images. In most cases relative paths are used locate the images. I am
    assuming that all your pages in your root folder work fine, but the logon
    page is in a subfolder. In this case you may need to modify the relative
    path to your image folder. If your images are located in an images subfolder,
    you might reference them using the syntax, "~/images/imagefile.jpg". Here
    the "~" is the virtual root of your application.

    Let us know how this works.

    EagleRed, May 8, 2009
    1. Advertisements

  3. GregoryJ

    GregoryJ Guest

    Thanks for getting back to me.

    My login.aspx page is in my root folder and my images are in the \images
    folder. I am referencing the images via "~\images\myImage.jpg", but they
    don't show. They appear in design time, but not when running the application.
    Plus, some of my images that aren't displayed are in my MasterPage.master
    file. In the Login page, the images in this file do not appear, but once
    logged in they do appear.

    In my web.config file to implement the Forms Authentication I am denying
    Access to everyone. When that's set, I am forced to login, when it's not set,
    I don't need to login.

    I'm assuming that may have something to do with it?

    Any suggestions on how I should proceed?
    GregoryJ, May 8, 2009
  4. GregoryJ

    GregoryJ Guest

    I just figured out what I'm doing wrong. SInce this is my first web-site that
    I'm pushing out to the web, I realized that I'm treating everything in my web
    application as Secured.

    What I did is I created a folder named "Secured" off of my root folder. In
    this folder I created a web.config file with the [deny users="?"] option set,
    while the root folder web.config file has [allow users="?"]. Thus, now my
    ~/images folder is not a secured location and my login.aspx page has access
    to the image files.

    GregoryJ, May 8, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.