启用跨应用重定向
我们在两台网络服务器上设置了负载平衡,但是,一些用户在被重定向到特定服务器上传文档时被要求登录(我们试图将所有上传的文档仅保留在一台服务器上) ),这是来自 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅负载平衡服务器上的 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.