.NET窗体身份验证在Azure中 - 需要什么样的变化为多个虚拟机? [英] .NET Forms Authentication in Azure - What changes are required for multiple VMs?

查看:131
本文介绍了.NET窗体身份验证在Azure中 - 需要什么样的变化为多个虚拟机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我们正在迁移我们的.NET Web应用程序到Azure云服务上多个​​节点的网络层运行(最初二)。我想知道我们应该如何修改我们的基于表单的认证机制,以在负载平衡环境中运行?这一点我们从来没有需要做过去那样我们的应用一直局限于只是一个物理服务器上的考虑。

We are currently migrating our .NET Web Application to an Azure Cloud Service with the Web tier running on multiple nodes (Initially two). I am wondering how we should modify our forms based authentication mechanism to run in a load balancing environment? This a consideration we have never needed to make in the past as our application has always been confined to just one physical server.

目前,我们确定我们在web.config保护的文件夹这样:

Currently we define our protected folders in the web.config as such:

<location path="secure-area">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>

在code在登录页面的工作原理是这样的:

The code in the login page works something like this:

if accountIsValid = true then
   FormsAuthentication.SetAuthCookie(sessionID, False)
   response.redirect("secure-area/index.aspx")
end if

然后活动会话检索整个像这样的应用程序:

Then the active session is retrieved throughout the application like this:

Dim sessionID as string = User.Identity.Name.ToString

presumably此方法不会自动存储在多个节点会话状态?我想,如果在Azure结构控制器将整理出这一切对我来说无需进行code的变化。一厢情愿的想法,也许!

Presumably this method will not automatically persist session state across multiple nodes? I wondered if the Azure Fabric Controller would sort all this out for me without having to make code changes. Wishful thinking maybe!

任何帮助或链接到在线指南将是非常美联社preciated!

Any help or links to online guides would be much appreciated!

推荐答案

这是少了约Azure的问题,了解如何使用负载平衡ASP.NET应用程序的窗体身份验证。 Forms身份验证使用服务器上的machineKey中,以发送到客户端的cookie中加密。默认情况下,这个键是随机每个实例的服务器上生成。为了让跨多个节点窗体身份验证的工作,你需要设置机器的关键在你的web.config横跨两个实例相同。下面是一些例子:

This is less a question about Azure, more about forms authentication using load balanced ASP.NET applications. Forms authentication uses the machineKey on the server to encrypt the cookie sent down to the client. By default, this key is randomly generated on the server per instance. To make forms auth work across multiple nodes you need to set the machine key to be the same across both instances in your web.config. Here are a few examples:

<一个href="http://stackoverflow.com/questions/3357850/does-forms-authentication-work-with-web-load-balancers">Does使用Web负载平衡器窗体身份验证的工作?

<一个href="http://msdn.microsoft.com/en-us/library/eb0zx8fc(v=vs.100).aspx">http://msdn.microsoft.com/en-us/library/eb0zx8fc(v=vs.100).aspx

http://support.microsoft.com/kb/910443

希望这个作品出来,编码快乐!

Hopefully this works out, happy coding!

这篇关于.NET窗体身份验证在Azure中 - 需要什么样的变化为多个虚拟机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆