1

这是我的第一篇文章,所以感谢大家的帮助:)

我有一个 asp.net mvc 3 Web 应用程序,我在其中添加了一个带有 jquery 移动功能的区域。我使用库 Facebook、Facebook.Web 和 Facebook.Web.Mvc ver 5.4.1.0 添加 facebook 登录。我在网站范围内没有问题,所以如果我登录 facebook 然后导航:

http://localhost:2508/Home

FacebookWebContext.Current.IsAuthenticated() //return true

但是,如果使用 jquery 移动应用程序导航该区域:

http://localhost:2508/MobileApp/Home

FacebookWebContext.Current.IsAuthenticated() //return false

我希望所有人都理解我

有什么建议么?

这是我的 _Layout 页面的 html:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>@ViewBag.Title</title>

        <link rel="stylesheet" href="@Url.Content("~/Content/MobileApp.min.css")" />
        <link rel="stylesheet" href="@Url.Content("~/Content/jquery.mobile.structure-1.3.2.min.css")" />

        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="@Url.Content("~/Scripts/CustomMobileInit.js")"></script>
        <script src="@Url.Content("~/Scripts/jquery.mobile-1.3.2.min.js")"></script>

    </head>
    <body>

        <div id="fb-root"></div>
        <script type="text/javascript">
            window.fbAsyncInit = function () {
                FB.init({ appId: '@Facebook.FacebookApplication.Current.AppId', channelURL: '@Request.Url.Scheme://@Request.Url.Authority@Url.Content("~/fbchannel.ashx")', cookie: true, xfbml: true, oauth: true });
                FB.Event.subscribe('auth.login', function (response) { window.location.reload(); });
                FB.Event.subscribe('auth.logout', function (response) { window.location.reload(); });
            };

            (function(d){
                var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
                js = d.createElement('script'); js.id = id; js.async = true;
                js.src = "//connect.facebook.net/en_US/all.js";
                d.getElementsByTagName('head')[0].appendChild(js);
            }(document));
        </script>

        <div data-role="page" id="MainPage" data-theme="a">

            <div data-role="header" data-position="fixed">
                <h3>
                    My Mobile App
                </h3>
            </div>

            <div data-role="content">

                @RenderBody()

            </div>

            <div data-role="footer" data-position="fixed">
                @{ dynamic me = Helpers.Utilities.FBGet("/me"); }
                @if (me != null)
                {
                    <h3>
                        @me.name
                    </h3>
                }
                else
                {
                    <h3>
                        Utente sconosciuto
                    </h3>
                }
            </div>

        </div>
    </body>
</html>

并且有一些页面实现了这个_Layout。我发现启用 ajax 时会出现问题。如果禁用 oAuth 正常工作,但我离开了页面转换。

4

0 回答 0