[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Login control placed in a content page renders improperly

Posted on 2010-11-22
Medium Priority
Last Modified: 2013-12-17
I have a login control placed in a content page with a master template applied.  The login control seems to be working okay (still testing), BUT the master page template is showing up just terrible.

The Company logo is missing (just a red "X"), the styles are gone, etc.  I'm not sure why this is because once I log in, all of the other content pages that use the same template show up as they should.  Anyone else have this problem?  

I suppose I could move the login control to a page outside the master template (on it's own) and manually configure everything so it looks the same, but I'd really rather not. That's just my "Plan B".
Question by:vcbertini
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 4
  • 2
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34191719
I suspect your master page is in the root folder, /, and is referencing images, stylesheets, etc. with URLs like "images/logo.jpg" - and your login page is in a sub-folder, /Login/, and when the page renders those URLs end up being interpreted as "/login/images/logo.jpg" - and since there is no such file, red X.

Use absolute paths in the master page, e.g. "/images/logo.jpg"

Author Comment

ID: 34191771
Actually, my master page and login page are in the same path (root).

This is the image source from my paster page:  src="images/frontend.jpg"
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34191783
If you like, post the code/markup for both pages.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 34191895
See below.
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="NRStemplate.master.cs" Inherits="NRStemplate" %>

<!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">
    <asp:ContentPlaceHolder id="head" runat="server">
    <link href="nrsstyle.css" rel="stylesheet" type="text/css" />
<form id="formdata" runat="server">
    <table cellpadding="10" cellspacing="0" title="NRS" 
            <td><img alt="logo" src="images/frontend.jpg" height="118" 
                    width="56" /></td>
            <td style="text-align: left">
            <div id="header">
            <h3>Keeping America&#39;s runaway and at-risk youth safe and off the streets.</h3>
         <h3>Call 1-800-RUNAWAY</h3></div></td>
            <td valign="top">
            <div id="navigation">
                <p><asp:HyperLink ID="navMain" runat="server" 
                        NavigateUrl="~/Organizations.aspx">Choose Organization</asp:HyperLink></p>
                <p><asp:HyperLink ID="navUpdate" runat="server"  
                        NavigateUrl="~/UpdateForm.aspx">Review/Update Profile</asp:HyperLink></p>
                <p><asp:HyperLink ID="navMOU" runat="server"  
                        NavigateUrl="~/MOU.aspx">Review Memorandum<br />of Understanding</asp:HyperLink></p>
                <p><asp:HyperLink ID="navPDF" runat="server"  
                        NavigateUrl="~/Compare.aspx">Proof/Print Changes</asp:HyperLink></p>
                <p><asp:HyperLink ID="navHelp" runat="server"  
                <p><asp:HyperLink ID="navPassword" runat="server"  
                        NavigateUrl="~/ChangePassword.aspx">Change Password</asp:HyperLink></p>
                    <asp:LoginStatus ID="lsOUT" runat="server" />
            <td align="left" valign="top">
            <asp:SiteMapPath ID="smpTop" runat="server" Font-Names="Verdana" 
                        Font-Size="0.8em" PathSeparator=" | ">
                        <CurrentNodeStyle ForeColor="#333333" />
                        <NodeStyle Font-Bold="True" ForeColor="#7C6F57" />
                        <PathSeparatorStyle Font-Bold="True" ForeColor="#5D7B9D" />
                        <RootNodeStyle Font-Bold="True" ForeColor="#5D7B9D" />
                    </asp:SiteMapPath><br /><br />
            <div id="main">
                 <asp:ContentPlaceHolder id="mainPlaceHolder" runat="server"></asp:ContentPlaceHolder>
            <td colspan="2">
            <div id="footer">
            <p>Copyright &copy; 2010</p>

Open in new window

<%@ Page Title="" Language="C#" MasterPageFile="~/NRStemplate.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="logMeIn" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="mainPlaceHolder" Runat="Server">
<div class="centered">
    <asp:Login ID="login" runat="server" BackColor="#F7F7DE" BorderColor="#CCCC99" 
        BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="10pt" 
            CssClass="center" membershipprovider="xxx" 
        <TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" />

Open in new window


Author Comment

ID: 34191911
Probably the weirdest thing is that it shows up under the "Design" tab in my development environment just fine.  I thought maybe it was a security control quirk, but I have a page with the "Change password" control on it and that one shows up normally.
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34191940
No, I think the fact there's a login control on this page is totally irrellevant, just coincidence.  As a test take out the login control, the page should continue to render incorrectly.

Aside from the multiple-folder scenario I metioned above, I can't imagine any reason that image shouldn't show up for one page if it does for others (assuming everything's in the same folder).  Maybe your browser cache just has a bad image in it or something - try refreshing the page while holding the CTRL key on the keyboard, and also try chaning the URLs for images etc to absolute paths, e.g. /images/frontend.jpg.

Author Comment

ID: 34192061
Okay, that's partly true. I took out the login control and just put in the word "test" and the page came up messed up (w/o style sheets).

I tried CTRL F5 - did nothing. Cleared my browser cache - no change.

Deleted the login.aspx page and created a new one without a login control - page came up without style sheets (even empty).

I put the login control back in, changed the url redirect back to itself, and once I was logged in, the login.aspx page showed up just fine (WITH style sheets).

This is the weirdest thing.
LVL 21

Expert Comment

by:Alfred A.
ID: 34230049
Assuming image is a sub folder in your web site and your master page is within the root,  You can try using an ASP.NET Image Control rather than HTML img if you want.   And then try getting the absolute path of the url from the relative path by using a tilde (~):

From this:

<img alt="logo" src="images/frontend.jpg" height="118"
                    width="56" />

To this:

<asp:Image ID="Image1" runat="server" ImageUrl = "~/images/frontend.jpg" Height="118px"
                    Width="56px" />


Author Comment

ID: 34230624
Unfortunately I tried that and it had the same result. The page never did recognize the style sheet, so I had to re-bulid the page manually (without the master template and style sheet) and build the styles directly into the page. That took care of most of the problems, but the image just will not show up and I cannot figure out why. I have tried everything - moving the image to the root folder, putting the image on another website and using the full http...url to reference it, using an image control, not using an image control, using a different image, etc. Nothing works.

The weirdest part is, this is only a problem before one logs in. After you log in, the image shows up just fine - even on the same page.
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34230883
Running into the same issue myself now...for some reason having a <style> tag directly in the page seems to work, but not if I <link> to a stylesheet.

Author Comment

ID: 34230944
The only thing I *haven't* tried is to set the image as a background image in the style sheet and apply that style to a table cell.  I'd really rather not do it that way, but it's worth a try. At this point I'd do anything to get the image to show up (it's a logo, so kind of necessary).
LVL 21

Expert Comment

by:Alfred A.
ID: 34230967
This is a bit of a long shot but can you try using a .gif image (anything that you can test) rather than a .jpg and test it out?  I had this sort of unexplained problem with jpg before and replacing it with gif, it worked.  I hope this helps.

Author Comment

ID: 34231197
Okay, more testing. I replaced the image with a .GIF and had the same problem. I set the background image with the .GIF and got nothing too.

Author Comment

ID: 34231243
Tried a .png too - didn't work.  Since this only has to do with not being logged in, I wonder if there's some weird authentication thing going on and it's blocking anything that's not secure (authenticated)? It's a theory.

Accepted Solution

vcbertini earned 0 total points
ID: 34231315
GOT IT! That was exactly it... did some research in Google and found that I should add this to my web.config file:

<location path="images">  
       <allow users="*"/>  

I think I may try that with my style sheet as well and see if I can go back to using the template like I want to. Not fond of having my login page outside the master template.  Thanks for everyone's input.

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question