如何获得“书呆子晚餐”? OpenID 弹出窗口工作

发布于 2024-12-05 18:52:04 字数 1747 浏览 0 评论 0原文

所以我尝试使用 NerdDinner 2 作为示例来实现 OpenID。当您单击其中一个 OpenID 提供商时,您会看到一个弹出窗口,如下图所示。我已经正确设置了大部分底层代码,并且我的登录页面加载并显示了三个提供程序按钮,但是当我单击它们时,没有弹出窗口。它根本没有任何作用。没有 JS 错误,只是什么也没发生。我缺少什么?

我已经查看了 NerdDinner 代码,但我无法准确找出导致弹出窗口发生的原因。我不一定需要有人告诉我我的应用程序出了什么问题,我只需要知道我在 NerdDinner 应用程序中寻找什么导致了这种情况发生,这样我就可以将它与我的应用程序进行比较。

我使用以下代码来呈现按钮:

@model dynamic
@using DotNetOpenAuth.Mvc;
@using DotNetOpenAuth.OpenId.RelyingParty;
<div id="login-oauth">
    <fieldset>
        <legend>via 3rd Party (recommended)</legend>
        @using (Html.BeginForm("LogOnPostAssertion", "Auth"))
        {
            @Html.Hidden("ReturnUrl", Request.QueryString["ReturnUrl"], new { id = "ReturnUrl" })
            @Html.Hidden("openid_openidAuthData")
            <div>
                @MvcHtmlString.Create(Html.OpenIdSelector(new SelectorButton[] {
new SelectorProviderButton("https://me.yahoo.com/", Url.Content("~/Content/images/yahoo.gif")),
new SelectorProviderButton("https://www.google.com/accounts/o8/id", Url.Content("~/Content/images/google.gif")),
new SelectorOpenIdButton(Url.Content("~/Content/images/openid.gif")),
}))
                <div class="helpDoc">
                    <p>
                        If you have logged in previously, click the same button you did last time!!
                    </p>
                </div>
            </div>
        }
    </fieldset>
</div>
@{     
    var options = new OpenIdSelector();
    options.TextBox.LogOnText = "Log On";
}
@MvcHtmlString.Create(Html.OpenIdSelectorScripts(options, null))

编辑:这种情况发生在所有浏览器中,并且没有弹出窗口阻止程序。

在此处输入图像描述

So I'm trying to implement OpenID using NerdDinner 2 as an example. When you click on one of the OpenID providers, you get a popup window that looks like the screenshot below. I've got most of the underlying code setup correctly and my login page loads and displays the three provider buttons, but when I click on them, there's no popup. It doesn't do anything at all. No JS errors, just nothing happens. What am I missing?

I've looked through the NerdDinner code but I'm having trouble trying to figure out exactly what causes the popup to occur. I don't necessarily need someone to tell me what's wrong with my app, I just need to know what I'm looking for in the NerdDinner app that causes it to happen so I can compare it with mine.

I'm using the following code to render the buttons:

@model dynamic
@using DotNetOpenAuth.Mvc;
@using DotNetOpenAuth.OpenId.RelyingParty;
<div id="login-oauth">
    <fieldset>
        <legend>via 3rd Party (recommended)</legend>
        @using (Html.BeginForm("LogOnPostAssertion", "Auth"))
        {
            @Html.Hidden("ReturnUrl", Request.QueryString["ReturnUrl"], new { id = "ReturnUrl" })
            @Html.Hidden("openid_openidAuthData")
            <div>
                @MvcHtmlString.Create(Html.OpenIdSelector(new SelectorButton[] {
new SelectorProviderButton("https://me.yahoo.com/", Url.Content("~/Content/images/yahoo.gif")),
new SelectorProviderButton("https://www.google.com/accounts/o8/id", Url.Content("~/Content/images/google.gif")),
new SelectorOpenIdButton(Url.Content("~/Content/images/openid.gif")),
}))
                <div class="helpDoc">
                    <p>
                        If you have logged in previously, click the same button you did last time!!
                    </p>
                </div>
            </div>
        }
    </fieldset>
</div>
@{     
    var options = new OpenIdSelector();
    options.TextBox.LogOnText = "Log On";
}
@MvcHtmlString.Create(Html.OpenIdSelectorScripts(options, null))

EDIT: This happens in all browsers and there are no popup blockers.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

-残月青衣踏尘吟 2024-12-12 18:52:04

由于某种原因,将 global.asax.cs 中的以下路由从: 更改

routes.MapRoute(
    "OpenIdDiscover",
    "Auth/Discover");

为:

routes.MapRoute(
    "OpenIdDiscover",
    "Auth/Discover",
    new { controller = "Auth", action = "Discover" }
);

似乎已经解决了问题。不知道为什么,但使用 Firebug 查看请求显示尝试访问此路由时出现 500 错误。

For some reason, changing the following route in global.asax.cs from:

routes.MapRoute(
    "OpenIdDiscover",
    "Auth/Discover");

to:

routes.MapRoute(
    "OpenIdDiscover",
    "Auth/Discover",
    new { controller = "Auth", action = "Discover" }
);

Seems to have fixed the problem. No idea why, but looking at the requests with Firebug showed a 500 error attempting to access this route.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文