在自动缩放的 Web 应用程序中使用 ViewState

Use of ViewState in an auto scaled web app

使用 ASP.NET 视图状态可能会在多服务器环境中引起问题。

Resolving view state message authentication code (MAC) errors

View state is information that is round-tripped between WebForms (.aspx) pages in an ASP.NET application. ...

Because the __VIEWSTATE field contains important information that is used to reconstruct the page on postback, make sure that an attacker cannot to tamper with this field. ...

To prevent this kind of tampering attack, the __VIEWSTATE field is protected by a message authentication code (MAC). ASP.NET validates the MAC that is submitted together with the __VIEWSTATE payload when a postback occurs.

有多种方法可以在多服务器环境中缓解此问题(在上面链接的文章中详细说明)。

是否需要在设置为自动缩放的 Azure Web 应用程序中应用这些方法?

根据您的描述,我检查了您提到的document关于解决视图状态消息验证码(MAC)的错误。

关于 Web 应用程序的案例 运行 在场(多服务器环境)中状态如下:

Some web hosting services, such as Microsoft Azure websites, take steps to synchronize each application's auto-generated key across their back-end servers. This lets applications that have not specified an explicit element to continue working in these environments, even if the application is running in a farm. If your application is running on a third-party hosting service, please contact your hosting provider to determine whether this situation applies to you.

此外,我尝试创建我的 ASP.NET WebForm 应用程序并部署到 Azure Web 应用程序(多个实例),它可以按预期工作。