Solved

Login control placed in a content page renders improperly

Posted on 2010-11-22
18
513 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
  • 10
  • 4
  • 2
18 Comments
 
LVL 33

Expert Comment

by:Todd Gerbert
Comment Utility
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
Comment Utility
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
Comment Utility
If you like, post the code/markup for both pages.
0
 

Author Comment

by:vcbertini
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:vcbertini
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Closing Comment

by:vcbertini
Comment Utility
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now