Solved

Web.config multiple frames and loginurl

Posted on 2004-09-03
6
860 Views
Last Modified: 2011-10-03
Hi all,

I have a web form created in asp.net which consists of multiple frames and I am having a problem which is slowly driving me mad.  The .aspx page is designed so that the central area of the screen is the frame that has the user interface.  The other frames act as a border around the outside.

I needed to have an area of the site which was secured and an unsecured area which I eventually found out could be done by using the <location> tag in the web.config file.  That's all fine. My problem is that I have a login.asox page which is specified in the web.config against the loginurl as follows: loginurl="login.aspx"

When the user tries to navigate to a page in the secure area directly I want the logon page to appear, which I can get it to if I'm not using frames and it will subsequently redirect me to the page initially requested.  Using my nice frameset I can't figure out how to get the login.aspx to appear in the frame called "mainframe" and then to automatically redirect me to the intially requested page, again displaying it in the "mainframe".

I feel there is bound to be a way to do this as other websites use frames and seem to do what I'm trying to achieve.

All help greatly appreciated.

Thanks in advance.
Nigel.
0
Comment
Question by:nigelbogle
[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
  • 2
  • 2
6 Comments
 
LVL 9

Assisted Solution

by:Thalox
Thalox earned 250 total points
ID: 11971310

Im not sure if I got you right.

You have a page in the "center" and some other borderpages around. and all information is shown in the center-page, right?

so if a resticted page should appear in the center, you save the "original" pagename to the session, redirect to the login, and when the login is correct, read the "original" pagename from the session and redirect to it.
all this should happen in the center page. the border wouldnt be affected, because the server doesnt know, that there are other pages around...

did this help, or misunderstood I something?


Thalox
0
 

Author Comment

by:nigelbogle
ID: 11971812
Hi there,

Thanks for the quick reply.  

I have an .aspx page which uses frames.  When I run my application the frames around the outside appear ok as does the centre frame with my start page on it.  If the user goes straight to the address bar and types in the url of a page in the protected area directly then the program is loading my loginurl specified in the web.config but it runs it as a single page and my frames disappear.

When I type in my details and get authenticated ok the Forms.RedirectFromLoginPage command does redirect but again to a single page.

Trying to get this all to work so that the directing and redirecting makes the page being directed or redirected to appear in my main frame is the problem.

Hope that helps.

Nigel
0
 
LVL 9

Assisted Solution

by:Thalox
Thalox earned 250 total points
ID: 11973023

I think the easiest (and in my opinion also the best) way is to check for the parent frames in the onload event of every page. (with javascript)
if the page has no parent, goto the frameset-page, and thats it. If the user wants to go to such a page, he has to use the links.

ok, you could implement the other logic, with the change between the frames and single page, but this could become very complicated, because of the jumps between server and client and the data you will have to save and restore every roundtrip.

so I would recommend to use the first method.

But if you still want to use the other one, and need further assistance, let me know.

Thalox
0
 
LVL 10

Accepted Solution

by:
jnhorst earned 250 total points
ID: 11976186
Consider using the <iframe></iframe> tag to imlpement your frames (if you are not already doing so), only give each iframe and id and runat="server".  Create an HTML table that has your layout so that you can put an <iframe> tag in each cell and create the layout like you want.  Here is a sample:

<table border="0" cellpadding="1" cellspacing="0" width="100%">
      <tr>
            <td width="200"><iframe id="frmLeft" runat="server" style="width: 100%; height: 600px" src=""></iframe></td>
            <td><iframe id="frmCenter" runat="server" style="width: 100%; height: 600px" src=""></iframe></td>
            <td width="200"><iframe id="frmRight" runat="server" style="width: 100%; height: 600px" src=""></iframe></td>
      </tr>
</table>

Since the <iframe> has runat=server, there will be an HtmlGenericControl class instance for each iframe.  You will put your various URLs in the src="" attribute.  You can assign or read this in server side code as follows:

frmLeft.Attributes("src") = "http://www.someurl.com"

You can also put javascript code in the pages that will show in these frames to access their parent document (your aspx page), and get one of the other iframe elements with getElementById and then call setAttribute("src", "some url") in client side javascript to show your login page in your center frame.  This would look like this:

// remember that this would be in the page apeearing in one of the frames.  Also, this IE javascript.  Don't know if or how well it will work CB.
<script language="javascript">
function chgURL()
{
                // this gets the document of the frame's parent.
      var parentDoc = document.parentWindow.parent.document;

                // this gets the other frame (my example just had frmLeft and frmRight).
      var otherFrm = parentDoc.getElementById("frmRight");

                // this resets the frame's src attribute.
      otherFrm.setAttribute("src", "http://www.msnbc.com");
}
</script>

John
0
 

Author Comment

by:nigelbogle
ID: 12158259
Hi Guys,

Thanks for your efforts.  Your answers, although not exactly what I was looking for pointed me in the right direction.  I eventually used a 3 x 3 html table and dropped a gridlayout component into the cell where I needed to put controls.  I also used wildcards for the outer cells so that they resized giving me the desired effect.

The results can be seen @ http://colossus.swiftsoft.com

Thanks for your help everyone.  I felt it only fair to split the points for your efforts and to qualify the solution here.

Cheers,
Nigel.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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