Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MVC应用程序未连接到Facebook_C#_Asp.net Mvc_Facebook - Fatal编程技术网

C# MVC应用程序未连接到Facebook

C# MVC应用程序未连接到Facebook,c#,asp.net-mvc,facebook,C#,Asp.net Mvc,Facebook,我有一个MVC应用程序,是作为POC构建的。当我在VisualStudio中运行它时,它连接到FB,我得到了一个访问令牌,一切都运行得很好。但是,当我将应用程序发布到IIS时,它不再连接。我得到了FB登录弹出窗口,输入我的用户名和密码,什么也没有发生。它似乎没有触发auth.authResponseChange更改事件。它没有击中任何警报。这是我正在使用的代码。我不知道该试什么 <script type="text/javascript"> window.fbAsyncInit =

我有一个MVC应用程序,是作为POC构建的。当我在VisualStudio中运行它时,它连接到FB,我得到了一个访问令牌,一切都运行得很好。但是,当我将应用程序发布到IIS时,它不再连接。我得到了FB登录弹出窗口,输入我的用户名和密码,什么也没有发生。它似乎没有触发auth.authResponseChange更改事件。它没有击中任何警报。这是我正在使用的代码。我不知道该试什么

<script type="text/javascript">
window.fbAsyncInit = function () {
    FB.init({
        appId: '<myappid>', // App ID
        status: true, // check login status
        cookie: true, // enable cookies to allow the server to access the session
        xfbml: true  // parse XFBML
    });


    FB.Event.subscribe('auth.authResponseChange', function (response) {
       alert("Connected!");
        if (response.status === 'connected') {
            var uid = response.authResponse.userID;
            var accessToken = response.authResponse.accessToken;
            alert(accessToken);
            window.location = "/Home/FacebookLogin?token=" + response.authResponse.accessToken;
        } else if (response.status === 'not_authorized') {
            alert("User not Authorized!");
        } else {
            alert("User not Logged in!");
        }
    });
};

// Load the SDK Asynchronously
(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));
有什么建议吗

谢谢


Rhonda

iis是否在同一台计算机上?如果没有,您可以使用Internet Explorer javascript内置调试器按F12调试javascript,然后转到“脚本”选项卡,这可能会有所帮助。它位于同一台计算机上。我只是发布了它,这样我就可以让我的团队中的其他人查看它进行测试,而不必将它发布到另一台计算机上。我仍然会尝试IE的内置JavaScript调试器或Firefox的Firebug,以查看是否发生无声异常。
public class HomeController : Controller
{
    public ActionResult Index(string token)
    {
        return View();
    }

    [HttpGet]
    public ActionResult FacebookLogin(string token)
    {
        HttpCookie accesstoken = new HttpCookie("accesstoken");
        accesstoken.Value = token;
        accesstoken.Expires = DateTime.Now.AddMinutes(10d);

        Response.Cookies.Add(accesstoken);

        return RedirectToAction("Index", "Home", new { token = token });
    }
}