启用跨应用重定向

发布于 2024-08-30 17:41:35 字数 1419 浏览 7 评论 0原文

我们在两台网络服务器上设置了负载平衡,但是,一些用户在被重定向到特定服务器上传文档时被要求登录(我们试图将所有上传的文档仅保留在一台服务器上) ),这是来自 web.config 的代码:

<authentication mode="Forms">
    <forms name="EAAAuthCookie" 
    loginUrl="/login" 
    defaultUrl="/members/home" 
    protection="All" 
    path="/" 
    timeout="60000" 
    slidingExpiration="true"
    enableCrossAppRedirects="true" />
</authentication>

<machineKey
decryption="AES"
validation="SHA1"
decryptionKey="key"
validationKey="key" />

这是上传表单的传输代码:

$('#addReport').click(function() {
            if ($.cookie('TransferURL') != '')
            {
                $("#iframeUploadReport").attr('src', $.cookie('TransferURL'));
            };

            $('#overlay').fadeIn('slow');
        });

<script type="text/C#" runat="server">
    void Page_Load()
    {
        string cookieName = FormsAuthentication.FormsCookieName;
        string userName = Request.Cookies["HiddenUsername"].ToString();
        string cookieValue = FormsAuthentication.GetAuthCookie(userName, false).Value;
        Response.Cookies["TransferURL"].Value = "/members/media-upload" + String.Format("?{0}={1}", cookieName, cookieValue);
    }
</script>

<iframe id="iframeUploadReport" src="/members/media-upload" width="500px" height="336px" frameborder="0" scrolling="no"></iframe>

您能看到我们遗漏的任何明显步骤吗?

谢谢

We have load balancing set up on out two web server, however, a few users are being asked to login when they are being re-directed to a particular server to upload a document (we are trying to keep all uploaded documents on one server only), here is the code from web.config:

<authentication mode="Forms">
    <forms name="EAAAuthCookie" 
    loginUrl="/login" 
    defaultUrl="/members/home" 
    protection="All" 
    path="/" 
    timeout="60000" 
    slidingExpiration="true"
    enableCrossAppRedirects="true" />
</authentication>

<machineKey
decryption="AES"
validation="SHA1"
decryptionKey="key"
validationKey="key" />

Here is the transfer code to the upload form:

$('#addReport').click(function() {
            if ($.cookie('TransferURL') != '')
            {
                $("#iframeUploadReport").attr('src', $.cookie('TransferURL'));
            };

            $('#overlay').fadeIn('slow');
        });

<script type="text/C#" runat="server">
    void Page_Load()
    {
        string cookieName = FormsAuthentication.FormsCookieName;
        string userName = Request.Cookies["HiddenUsername"].ToString();
        string cookieValue = FormsAuthentication.GetAuthCookie(userName, false).Value;
        Response.Cookies["TransferURL"].Value = "/members/media-upload" + String.Format("?{0}={1}", cookieName, cookieValue);
    }
</script>

<iframe id="iframeUploadReport" src="/members/media-upload" width="500px" height="336px" frameborder="0" scrolling="no"></iframe>

Can you see any obvious step we are missing?

Thanks

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

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

发布评论

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

评论(1

可爱咩 2024-09-06 17:41:35

请参阅负载平衡服务器上的 ASP.NET 表单身份验证

为了使表单身份验证在负载平衡的环境中工作,您需要使两个应用程序使用相同的计算机密钥。只需按照链接中的说明进行操作即可。

See ASP.NET Forms Authentication on Load Balanced Servers.

To make forms authentication work in a load balanced environment, you need to make both applications use the same machine key. Just follow the instructions in the link.

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