Require Login

Feb 26, 2010 at 10:04 PM

I'm using 3.01 for my multipage iFrame application.  All is working well, thankfully!  I'm using a Master Page, per tutorials and advice.  Per the code below, I can set require login for all pages via the Master Page.

How do I "turn off" require login for some of the pages that utilize my Master Page for formatting, menu, etc.?

using Facebook;
using Facebook.Schema;
using Facebook.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class IFrameMaster : Facebook.Web.CanvasIFrameMasterPage
{
    public IFrameMaster()
    {
        RequireLogin = true;
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
Any help would be welcomed and greatly appreciated.
Thanks!
LuoLong
Feb 27, 2010 at 7:01 PM

Anyone here?  Any ideas on how to solve this?

Mar 1, 2010 at 2:41 PM

Bump.

Mar 5, 2010 at 6:48 AM

you have to set require login to false before CanvasIFrameMasterPage.OnInit()

Mar 10, 2010 at 5:17 PM
stringa wrote:

you have to set require login to false before CanvasIFrameMasterPage.OnInit()

stringa-

Just got back into town, and saw your response.  Thank You!  I understand the idea of your response, but I do not know how to implement it.

Do I set the login to false on the pages where I don't want to require a login?  A specific example would and further explanation would be greatly appreciated.

Sincerest regards,

LuoLong

Mar 12, 2010 at 12:46 AM

You need to look up the ASP.NET page life cycle. -- http://msdn.microsoft.com/en-us/library/ms178472.aspx

 

Also, use this page from some more details on the working on master pages : http://odetocode.com/code/450.aspx . There's heaps on information out there on the lifecycle when using master pages as well, so google is your friends.

 

First things first, you would be best off removing the constructor from the IFrameMaster, and putting in a Page_PreInit with the RequireLogin = true;

After this, for your content pages, out a Page_PreInit in them as well, and use this.Master (with correct casting to either CanvasIFrameMasterPage / CanvasFBMLMasterPage), to set the RequireLogin on the master page FROM the content PreInit.

This works because the PreInit of the content page is run after that of the master page. Be aware however, that the master page / content page event order is different for different events in the page lifecycle.

Mar 25, 2010 at 6:51 PM
owenberry wrote:

You need to look up the ASP.NET page life cycle. -- http://msdn.microsoft.com/en-us/library/ms178472.aspx

 

Also, use this page from some more details on the working on master pages : http://odetocode.com/code/450.aspx . There's heaps on information out there on the lifecycle when using master pages as well, so google is your friends.

 

First things first, you would be best off removing the constructor from the IFrameMaster, and putting in a Page_PreInit with the RequireLogin = true;

After this, for your content pages, out a Page_PreInit in them as well, and use this.Master (with correct casting to either CanvasIFrameMasterPage / CanvasFBMLMasterPage), to set the RequireLogin on the master page FROM the content PreInit.

This works because the PreInit of the content page is run after that of the master page. Be aware however, that the master page / content page event order is different for different events in the page lifecycle.

owenberry-

Thank you for your assistance.  After using the links you provided along with some additional research on Codeplex and via Google, I implemented the Page_PreInit to serve up pages in my Facebook app with and without login requirements. 

Your advice was a huge help.  As help to others, I will post the code that worked for me.

LuoLong

Mar 25, 2010 at 10:14 PM

Using the help from owenberry, here's how I set login for some pages and not for others using a MasterPage.

Master Page:

using Facebook;
using Facebook.Schema;
using Facebook.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class IFrameMaster : Facebook.Web.CanvasIFrameMasterPage
{
    
    protected void Page_PreInit(object sender, EventArgs e)
    {
        RequireLogin = true;
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

Content Page with ReguireLogin = true:

using Facebook;
using Facebook.Schema;
using Facebook.Web;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Console : System.Web.UI.Page
{
 
    protected void Page_PreInit(object sender, EventArgs e)
    {
        this.Master.RequireLogin = true;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }
}

Content Page with RequireLogin = false:

using Facebook;
using Facebook.Schema;
using Facebook.Web;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{

    protected void Page_PreInit(object sender, EventArgs e)
    {
        this.Master.RequireLogin = false;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }
}