如何调用 Forms Auth 登录模式对话框而不是重定向到 loginUrl 登录页面?

发布于 2024-10-08 17:50:20 字数 726 浏览 0 评论 0原文

我刚刚为我的 ASP.NET 网站实现了模式对话框登录弹出窗口。这种体验与您在 DIGG.com 上获得的体验类似。登录时,您会看到一个精美的弹出模式对话框(由 JQuery Tools Overlay 控件提供)。该对话框是母版页中的 ASCX 文件,因此全局可用。它使用 PageMethod 来验证当前用户。如果验证成功,我会在 PageMethod 的成功回调中调用 window.location.reload();

当登录不需要身份验证的页面时,这非常有用,但是当非身份验证用户尝试导航到需要身份验证的页面时该怎么办?

是否可以修改我的 web.config 文件,以便我只需调用模式对话框,而不是为未经身份验证的用户重定向到 SignIn.aspx 页面?

假设一个未经身份验证的用户位于不需要身份验证的 Default.aspx 上。他想要导航到需要身份验证的“Add.aspx”。使用模式对话框弹出窗口处理此问题的最佳方法是什么?

如果我必须使用专用页面,我想我只会有一个 SignIn.aspx 页面,该页面在加载时调用对话框,如果身份验证成功,它将使用 JavaScript 重定向到目标页面。

但理想情况下,我想从 Default.page 进行登录,然后使用脚本重定向到“Add.aspx”。

I've just finished implementing a modal dialog login popup for my ASP.NET website. The experience is similar to what you get with DIGG.com. When you log in, you get a fancy popup modal dialog (provided by the JQuery Tools Overlay control). The dialog is an ASCX file in the Master Page, so it's available globally. It uses a PageMethod to validate the current user. If the validation succeeds, I call window.location.reload(); in the PageMethod's success callback.

This works great when logging in on a page that doesn't require authentication, but what about when non-auth users are trying to navigate to a page that requires auth?

Is it possible to modify my web.config file so that instead of redirecting to a SignIn.aspx page for non-authenticated users I simply invoke the modal dialog instead?

Let's say a non-authenticated user is on Default.aspx which doesn't require auth. He wants to navigate to "Add.aspx" which does require auth. What's the best way to handle this with a modal dialog popup?

If I have to use a dedicated page, I guess I'll just have a SignIn.aspx page that invokes the dialog when it loads and if authentication succeeds, it'll use JavaScript to redirect to the destination page.

But ideally, I'd like to do the login from the Default.page and then redirect to "Add.aspx" with script.

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

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

发布评论

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

评论(1

深海少女心 2024-10-15 17:50:20

由于我没有得到任何反馈,所以我继续按照常规“解决”这个问题。我仍然有一个专用的 Login.aspx 页面,但它仅在用户直接导航到需要身份验证的页面的情况下使用。

在本例中,我让 ASP.NET 重定向到 Login.aspx,然后使用客户端脚本调用弹出对话框。我使用 WebMethod 进行正常身份验证,然后根据需要进行重定向。如果用户取消对话框,我只需重定向回 Default.aspx。

似乎无法回避对专用登录页面的需求。

Since I didn't get any feedback and went ahead and "solved" this issue conventionally. I still have a dedicated Login.aspx page but it's only used in cases where users navigate directly to a page requiring authentication.

In this case, I let ASP.NET redirect to the Login.aspx, and then using client script I invoke the popup dialog. I do the normal authentication using a WebMethod and then redirect as needed. If the user cancels the dialog, I just redirect back to Default.aspx.

Seems like there's no getting around the need for a dedicated Login page.

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