asp.net-mvc IsolateApps 导致指定的解密密钥具有无效的十六进制字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15002960/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 02:36:51  来源:igfitidea点击:

IsolateApps causes Decryption key specified has invalid hex characters

asp.net-mvcencryptionmachinekey

提问by WernerVA

I working on a MVC 4 site which has uses Authentication. The site requires that I specify the Machine Key values. I did this via the IIS interface having deselected the "automatically generate at runtime", generated the key values and having selected "generate a unique key for each application"

我在使用身份验证的 MVC 4 站点上工作。该站点要求我指定机器密钥值。我是通过 IIS 界面完成的,取消选择“在运行时自动生成”,生成键值并选择“为每个应用程序生成唯一键”

The web.config entry looks something like this:

web.config 条目如下所示:

<machineKey decryption="DES" decryptionKey="{hex-key value},IsolateApps" 
    validationKey="{hex-key value},IsolateApps" />;

While this seems to work fine on another web project it causes the "Decryption key specified has invalid hex characters" error on the dev machine I am working on now (both in IIS-Express and IIS 7.5).

虽然这在另一个 web 项目上似乎工作正常,但它会导致我现在正在使用的开发机器上的“指定的解密密钥具有无效的十六进制字符”错误(在 IIS-Express 和 IIS 7.5 中)。

Removing ",IsolateApps"from the key values solves the issue but since I need this option on in production I dont want to be removing it now only to have this issue when deploying.

",IsolateApps"从键值中删除解决了这个问题,但由于我在生产中需要这个选项,我不想现在删除它只是为了在部署时出现这个问题。

What gives? The dev box is a SQL 2008 R2 box with .net 2.0 and .net 4.0.

是什么赋予了?开发箱是带有 .net 2.0 和 .net 4.0 的 SQL 2008 R2 箱。

回答by Joe Daley

The IsolateAppsmodifier causes ASP.NET to generate a unique key for each application on your server. This is only applicable if you are getting ASP.NET to auto-generate keys at runtime.

IsolateApps修改使ASP.NET为您的服务器上的每个应用程序的唯一关键。这仅适用于让 ASP.NET 在运行时自动生成密钥的情况。

If you are not getting ASP.NET to auto-generate keys, and are instead specifying the keys using decryptionKey="{hex-key value}", then the way to get ASP.NET to use a different key for each application is to simply specify a different key in each application's Web.config.

如果您没有让 ASP.NET 自动生成密钥,而是使用 指定密钥decryptionKey="{hex-key value}",那么让 ASP.NET 为每个应用程序使用不同密钥的方法是简单地在每个应用程序的 Web 中指定不同的密钥。配置。

The IIS config GUI allows you to create a Web.config with an explicit key together with the IsolateAppsmodifier, which is invalid, and in my opinion is a bug in the config GUI.

IIS 配置 GUI 允许您使用显式键和IsolateApps修饰符创建 Web.config ,这是无效的,在我看来,这是配置 GUI 中的一个错误。

回答by JDeVil

You can fix the issue by adding the following to the machineKey element (compatibilityMode="Framework20SP1") in the web.config See Link

您可以通过将以下内容添加到 web.config 中的 machineKey 元素 (compatibilityMode="Framework20SP1") 来解决此问题,请参阅链接

回答by Jrud

This can be fixed by adding the machineKey line into your web.config, and specifying your keys as shown below (use your own key though of course, this one is easily guessable):

这可以通过将 machineKey 行添加到您的 web.config 中来解决,并如下所示指定您的密钥(当然,使用您自己的密钥,这个很容易猜到):

<configuration>
 <system.web>
  <machineKey decryptionKey="0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0" validationKey="0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF00123456789ABCDEF0123456789ABCDEF0123456789ABCDEF00123456789ABCDEF0123456789ABCD" />
 </system.web>
</configuration>