Skip to content

We recommend that deployed versions of Orchard are configured with a fixed machine key rather than the default setting, which is to automatically generate the key at runtime. This default setting can cause the key to change unexpectedly, which can cause validation errors.

我们建议部署的Orchard版本配置固定的机器密钥而不是默认设置,即在运行时自动生成密钥。此默认设置可能导致密钥意外更改,这可能导致验证错误。

Setting Up the Machine Key Using IIS Manager

使用IIS管理器设置计算机密钥

If you have access to the IIS management console for the server where Orchard is installed, it is the easiest way to set-up a machine key.

如果您可以访问安装了Orchard的服务器的IIS管理控制台,则这是设置计算机密钥的最简单方法。

Start the management console and then select the web site. Open the machine key configuration:

启动管理控制台,然后选择该网站。打开机器密钥配置:

The IIS web site configuration panel

The machine key control panel has the following settings:

机器钥匙控制面板具有以下设置:

The machine key configuration panel

Uncheck "Automatically generate at runtime" for both the validation key and the decryption key.

取消选中验证密钥和解密密钥的“在运行时自动生成”。

Click "Generate Keys" under "Actions" on the right side of the panel.

单击面板右侧“操作”下的“生成密钥”。

Click "Apply".

单击“应用”。

Setting Up the Machine Key Directly in the Web.config File

直接在Web.config文件中设置机器密钥

If you do not have access to the IIS management console, it is still possible to set-up a machine key for an Orchard application.

如果您无权访问IIS管理控制台,则仍可以为Orchard应用程序设置计算机密钥。

To do so, open the web.config file that is at the root of the Orchard web site. The machine key settings can be found or created under configuration/system.web:

为此,请打开位于Orchard网站根目录的web.config文件。可以在configuration / system.web下找到或创建机器密钥设置:

<configuration>

  <system.web>

    <machineKey decryptionKey="Decryption key goes here,IsolateApps"

                validationKey="Validation key goes here,IsolateApps" />

  </system.web>

</configuration>

To create the keys that go into the placeholders above, you can use one of the available online generators, such as:

要创建进入上述占位符的键,您可以使用其中一个可用的在线生成器,例如: