0

我有一个带有登录按钮的主屏幕。当用户单击登录按钮时,登录视图必须在对话框(弹出窗口)中打开。这里的扭曲是主屏幕和登录屏幕是两个子域中的两个不同的应用程序。所以我必须在 my.sample.com 应用程序的对话框(弹出窗口)中打开 auth.sample.com 的登录视图。对不起英语不好。请看下面的代码:

<p>
  <button type="submit" name="PopupLoginbutton" id = "PopupLoginbutton" value="Popbutton">Login</button> 
</p>
<div id="dialog" title="Login" style="overflow: hidden;"> 
<script type="text/javascript">
$(function () {
    $('#dialog').dialog({
        autoOpen: false,
        width: 400,
        resizable: false,
        title: 'hi there',
        modal: true,
        open: function (event, ui) {
                           $(this).load("http://auth.sample.com/");
        },
        buttons: {
            "Close": function () {
                $(this).dialog("close");
            }
        }
    });

    $('#PopupLoginbutton').click(function () {
                  $('#dialog').dialog('open');
    });
}); 
</script> 
4

2 回答 2

0

If I understand your position correctly, you want to provide access to content or an area of your site, but only if users are logged in. Are you looking to provide log in capabilities to your new site through the existing auth of your subdomain?

Unfortunately this won't work as you describe, if you're using common methods for authentication and authorization. Logging into a different sub domain isn't going to get you where you're trying to go. I can't log into my bank and then check my email.

You can POST wherever you like or even use JS to load content from other sites/domains (if the end-users permissions/config allow), but your token in the browser to represent a logged in user won't carry over from one domain to the next.

There are several approaches, here are a couple of common ones:

  1. Create a custom MembershipProvider and RoleProvider. These would allow you to use the server-side logic you already have to your access your authentication service.
  2. Configure your new site to use the same membership provider (and database) that the subdomain is using.
  3. Build a web service and tokenization strategy to expose identity from your existing subdomain, and incorporate that into your site.

Number 2 is the easiest, if you own the subdomain. Number 1 isn't too hard if you can wrap the calls to the membership service. If your subdomain is third party, however, and it locks up the user database then you won't have much luck here, unless they provide a means to wrap their login services.

Hope this helps some.

Cheers.

于 2012-09-07T20:19:47.517 回答
0

只有在当前 MVC3 项目中才能访问视图。如果您只想显示登录屏幕,您应该使用完整的 URL (http://my.sample.com/login) 显示弹出窗口。

如果您想将信息传递给登录应用程序,则必须使用表单和 POST/GET 到完整 URL。

于 2012-09-07T20:16:27.760 回答