Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Framing Heck

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-20 : 09:19:32
I'm trying to create an ASP.NET 1.1 application using forms authentication



At one point I am trying to use frames (but am very open to alternative suggestions that give the same results). With the frames I have a navigation bar at the top and a Word document in the bottom frame.

My problem is that when I try to open the app by entering the URL directly, the forms authentication page opens in each frame rather than in a single page as it normally would. Does anyone have any idea how I go about preventing this?

many thanks



steve


-----------

Oh, so they have internet on computers now!

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-06-20 : 09:40:23
I'd suggest using an iframe instead of a regular frame. It's part of W3C standard for a while now, so compatibility shouldn't be an issue. I don't know if it will solve your problem though.

You may need to add some JavaScript to your framed pages to check if they have a parent window or not. If they do, you may be able to intercept the form authentication call to prevent it from showing up in the frame.
Go to Top of Page

JBelthoff
Posting Yak Master

173 Posts

Posted - 2006-06-20 : 17:01:12
You could do a seperate non-frame login page. Then after the user is authenticated direct them to the frame design.

You would need to do a custom authentication redirect to redirect all non authenticated users to the login page.

Sounds like each frame is redirecting to the login rather than the page as a whole. You must be using the standard authentication redirect no?

Hope that helps.



JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
• Position SEO can provide your company with SEO Services at an affordable price
› As far as myself... I do this for fun!
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-21 : 03:45:01
quote:
I'd suggest using an iframe


What are the advantages of this?

quote:
You could do a seperate non-frame login page. Then after the user is authenticated direct them to the frame design.


I must admit I hadn't thought of that but it could work for the group of users who will use the frames page. My main reason for not considering it is that the frames based page is only a small part of the app. Most of the rest (so far) doesn't use them

quote:
You would need to do a custom authentication redirect to redirect all non authenticated users to the login page.


That sounds as though it may be beyond my current skills. Do you know of any good sites that might explain it?

quote:
You must be using the standard authentication redirect no


Yes I am using the standard forms authentication functionality.

I've considered some sort of javascript "break out of frames" but I'm not sure that helps either. The whole frames thing seems to be a problem. I was going to use session state variables (as I have a low number of users and so server memory shouldn't be a problem) but I read that each page in a frame has it's own session.

thanks to both for your replies

steve

-----------

Oh, so they have internet on computers now!
Go to Top of Page

JBelthoff
Posting Yak Master

173 Posts

Posted - 2006-06-21 : 07:16:02
Hi Steve,

Yes standard forms authentication will redirect all pages in that directory to the login page that you specify. So if you go to the frames page, which is actually 2 pages displyed in one, each will be redirected to the login. Thats why each of your frames shows the login.

To use custom, you would need to manually authenticate each page like this:

If Not User.Identity.IsAuthenticated Then
'Redirect Somewhere
Else
'Something Else
End If


To manually login in user you would need to write an encrypted cookie for the forms authentication.

Imports System.Web.Security

Dim ticket As FormsAuthenticationTicket = New FormsAuthenticationTicket(1, ui.Email.ToLower, DateTime.Now, DateTime.Now.AddMinutes(30), SaveCookie, objStr.ToString, FormsAuthentication.FormsCookiePath)
Dim encTicket As String = FormsAuthentication.Encrypt(ticket)

If SaveCookie Then
Response.Cookies.Add(New System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encTicket))
Response.Cookies(FormsAuthentication.FormsCookieName).Expires = DateTime.MaxValue
Else
Response.Cookies.Add(New System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encTicket))
End If


You can go here for more: [url]http://msdn2.microsoft.com/en-us/system.web.security.formsauthenticationticket(VS.80).aspx[/url]


JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
• Position SEO can provide your company with SEO Services at an affordable price
› As far as myself... I do this for fun!
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-21 : 07:31:50
Thats fantastic, thanks so much.


Steve

-----------

Oh, so they have internet on computers now!
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-06-21 : 09:42:20
To me, the main advantage of the iframe is that it doesn't require the FRAMESET page structure. I've found that designing pages as frames-only was more troublesome that just designing them normally and slotting them in with an IFRAME if I wanted to. Just a personal preference.
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2006-06-21 : 10:29:15
Cheers, Rob

I'll take a look at iframes properly

steve


-----------

Oh, so they have internet on computers now!
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-06-21 : 11:58:09
or you could be fancy
and put your menu in a floating div tag that is always displayed at the top of the page.

Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]
Go to Top of Page
   

- Advertisement -