How can I set the attribute RequireLogin for an FBML ASP.NET MVC canvas application ?

Nov 24, 2009 at 4:42 AM

My application is an FBML canvas application, built using the Facebook Developer Toolkit for ASP.NET MVC framework, it's hosted on a fan page of Facebook so I don't use the Facebook Connect Login.

To make sure user must login into Facebook before using my application, I know If we use ASP.NET WebForms, we can simply inherite from the CanvasIFrameMasterPage and  set the attribute RequireLogin  in the constructor IFrameMaster like below:

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

But I have to use the ASP.NET MVC framework. So is there anyone please tell me how I can set the attribute RequireLogin ?

Thanks in advanced.

Nov 24, 2009 at 8:39 AM

using Facebook.Web.Mvc;

public class HomeController : Controller {

  private const string REQUIRED_PERMISSIONS = "status_update,........";

  [FacebookAuthorization(IsFbml = true, RequiredPermissions = REQUIRED_PERMISSIONS)]

  public ActionResult Index()

  {

     var api = this.GetApi();

      return View();

  }

}

Nov 24, 2009 at 9:38 PM

That's great. It worked. Thank you very very very much.

But is there anyway to make sure users have to login before using my application but don't request accept any required permissions ?

Thanks again

Nov 25, 2009 at 2:34 AM

Hi,

RequiredPermissions is optional.

Are you Vietnamese? My YM: thonglinhma@yahoo.com