Login control placed in a content page renders improperly

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".
vcbertiniAsked:
Who is Participating?
 
vcbertiniConnect With a Mentor Author Commented:
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">  
   <system.web>  
     <authorization>  
       <allow users="*"/>  
     </authorization>  
   </system.web>  
 </location>

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.
0
 
Todd GerbertIT ConsultantCommented:
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"
0
 
vcbertiniAuthor Commented:
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"
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
Todd GerbertIT ConsultantCommented:
If you like, post the code/markup for both pages.
0
 
vcbertiniAuthor Commented:
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">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <link href="nrsstyle.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="formdata" runat="server">
    <table cellpadding="10" cellspacing="0" title="NRS" 
        width="100%">
        <tr>
            <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>
        </tr>
        <tr>
            <td valign="top">
            <div id="navigation">
               <p>&nbsp;</p>
                <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"  
                        NavigateUrl="~/Help.aspx">Instructions/Help</asp:HyperLink></p>
                <p><asp:HyperLink ID="navPassword" runat="server"  
                        NavigateUrl="~/ChangePassword.aspx">Change Password</asp:HyperLink></p>
                <p>
                    <asp:LoginStatus ID="lsOUT" runat="server" />
                </p>
            </div>
            </td>
        
            <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>
            </div>
            </td>
        </tr>
        
        <tr>
            <td colspan="2">
            <div id="footer">
            <p>Copyright &copy; 2010</p>
            </div></td>
        </tr>
               
    </table>
    </form>
</body>
</html>

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>
<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" 
            DestinationPageUrl="~/Help.aspx">
        <TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" />
    </asp:Login></div>
</asp:Content>

Open in new window

0
 
vcbertiniAuthor Commented:
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.
0
 
Todd GerbertIT ConsultantCommented:
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.
0
 
vcbertiniAuthor Commented:
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.
0
 
Alfred A.Commented:
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" />

0
 
vcbertiniAuthor Commented:
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.
0
 
Todd GerbertIT ConsultantCommented:
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.
0
 
vcbertiniAuthor Commented:
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).
0
 
Alfred A.Commented:
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.
0
 
vcbertiniAuthor Commented:
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.
0
 
vcbertiniAuthor Commented:
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.
0
 
vcbertiniAuthor Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.