?
Solved

Login control placed in a content page renders improperly

Posted on 2010-11-22
18
Medium Priority
?
521 Views
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".
0
Comment
Question by:vcbertini
[X]
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
18 Comments
 
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"
0
 

Author Comment

by:vcbertini
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"
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34191783
If you like, post the code/markup for both pages.
0
A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

 

Author Comment

by:vcbertini
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">
    <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
 

Author Comment

by:vcbertini
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.
0
 
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.
0
 

Author Comment

by:vcbertini
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.
0
 
LVL 21

Expert Comment

by:Alfred1
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" />

0
 

Author Comment

by:vcbertini
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.
0
 
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.
0
 

Author Comment

by:vcbertini
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).
0
 
LVL 21

Expert Comment

by:Alfred1
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.
0
 

Author Comment

by:vcbertini
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.
0
 

Author Comment

by:vcbertini
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.
0
 

Accepted Solution

by:
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">  
   <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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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