MachineKey生成
https://support.microsoft.com/zh-cn/help/2915218/resolving-view-state-message-authentication-code-mac-errors#appendixa
安全警告:
只需单击一下按钮,您就可以通过许多网站生成 <machineKey> 元素。切勿使用通过这些网站获得的 <machineKey> 元素。这些密钥是否安全创建或者是否记录到秘密数据库,都无从而知。必须使用您自己创建的 <machineKey> 配置元素。
打开PowerShell然后粘贴以下代码回车
1 # 生成一个可复制并粘贴到 Web.config 文件中的 <machineKey> 元素。 2 function Generate-MachineKey { 3 [CmdletBinding()] 4 param ( 5 [ValidateSet("AES", "DES", "3DES")] 6 [string]$decryptionAlgorithm = 'AES', 7 [ValidateSet("MD5", "SHA1", "HMACSHA256", "HMACSHA384", "HMACSHA512")] 8 [string]$validationAlgorithm = 'HMACSHA256' 9 ) 10 process { 11 function BinaryToHex { 12 [CmdLetBinding()] 13 param($bytes) 14 process { 15 $builder = new-object System.Text.StringBuilder 16 foreach ($b in $bytes) { 17 $builder = $builder.AppendFormat([System.Globalization.CultureInfo]::InvariantCulture, "{0:X2}", $b) 18 } 19 $builder 20 } 21 } 22 switch ($decryptionAlgorithm) { 23 "AES" { $decryptionObject = new-object System.Security.Cryptography.AesCryptoServiceProvider } 24 "DES" { $decryptionObject = new-object System.Security.Cryptography.DESCryptoServiceProvider } 25 "3DES" { $decryptionObject = new-object System.Security.Cryptography.TripleDESCryptoServiceProvider } 26 } 27 $decryptionObject.GenerateKey() 28 $decryptionKey = BinaryToHex($decryptionObject.Key) 29 $decryptionObject.Dispose() 30 switch ($validationAlgorithm) { 31 "MD5" { $validationObject = new-object System.Security.Cryptography.HMACMD5 } 32 "SHA1" { $validationObject = new-object System.Security.Cryptography.HMACSHA1 } 33 "HMACSHA256" { $validationObject = new-object System.Security.Cryptography.HMACSHA256 } 34 "HMACSHA385" { $validationObject = new-object System.Security.Cryptography.HMACSHA384 } 35 "HMACSHA512" { $validationObject = new-object System.Security.Cryptography.HMACSHA512 } 36 } 37 $validationKey = BinaryToHex($validationObject.Key) 38 $validationObject.Dispose() 39 [string]::Format([System.Globalization.CultureInfo]::InvariantCulture, 40 "<machineKey decryption=`"{0}`" decryptionKey=`"{1}`" validation=`"{2}`" validationKey=`"{3}`" />", 41 $decryptionAlgorithm.ToUpperInvariant(), $decryptionKey, 42 $validationAlgorithm.ToUpperInvariant(), $validationKey) 43 } 44 }
对于 ASP.NET 4.0 应用程序,您只需调用 Generate-MachineKey(不带参数),就能生成 <machineKey> 元素,如下所示:
PS> Generate-MachineKey
<machineKey decryption="AES" decryptionKey="..." validation="HMACSHA256" validationKey="..."/>
ASP.NET 2.0 和 3.5 应用程序不支持 HMACSHA256。您可以改为指定 SHA1 来生成一个兼容的 <machineKey> 元素,如下所示:
PS> Generate-MachineKey -validation sha1
<machineKey decryption="AES" decryptionKey="..." validation="SHA1" validationKey="..."/>
转载于:https://www.cnblogs.com/Excelsior/p/7390290.html
MachineKey生成相关推荐
- MachineKey
我是在收到用户发来的这个错误信息的截图后才认识到什么是MachineKey的. 有关MachineKey的概念.MachineKey的生成以及web.config文件中的配置,网上一搜一大堆,为了方便 ...
- 在.NET Core中使用MachineKey
在.NET Core中使用MachineKey 在上篇文章中,我介绍了 Cookie是基于 MachineKey生成的, MachineKey决定了 Cookie生成的算法和密钥,并如果使用多台服务器 ...
- machinekey设置相关
http://blog.csdn.net/huwei2003/article/details/4647008 ASP.net2.0的machineKey machineKey的作用在于下述场景: A ...
- 验证视图状态 MAC 失败,配置machineKey
在webconfig中system.web节点下添加: <system.web><machineKey validationKey="3FF1E929BC0534950B0 ...
- ASP.NET machineKey的作用和使用方法
ASP.NET machineKey的作用 如果你的Asp.Net程序执行时碰到这种错误:"验证视图状态 MAC 失败.如果此应用程序由网络场或群集承载,请确保 <machineKey ...
- 验证视图状态MAC失败问题正确的解决办法
今天做了个首页登陆的页面,是用Request.Form接收参数的 然后又做了个测试页面test.aspx,代码如下: <body> <form id="form1& ...
- 解决网站在负载均衡环境下SESSION丢失的问题
在WEB场中,动态网页往往会因为几台主机做了负载而产生SESSION丢失的问题,网上也有很多的介绍,我这里只将我经历的过程给大家分享一下: 系统要运行在负载平衡的 Web 场环境中,而系统配置文件we ...
- asp.net mvc4开启SqlServer 会话共享模式
2019独角兽企业重金招聘Python工程师标准>>> 应用部署结构(精简): 站点部署在Nginx后面,以Nginx作为反向代理,不希望在Nginx上设置ip_hash,实现比较真 ...
- 转:asp.net 负载平衡-Session相关
来自:http://www.cnblogs.com/zxylonely/archive/2009/12/23/1630197.html http://blog.csdn.net/lvlingwy/ar ...
最新文章
- 点击windows live writer无反应 / 使用windows live writer的前提
- matlab创建nc文件怎么打开,MATLAB打开nc文件并读取nc文件数据
- Atitit mybatis使用简明教程 目录 1.1. Mybatis.xml 配置文件	1 1.2. Datamp.xml mapper文件主要作用是分模块放sql语句	2 1.3. 查询
- 获取秒级时间戳与毫秒级时间戳
- 图书馆管理系统【SSM含SQL文件】
- 安卓Tv端App开发与手机端的开发的区别
- 当幻想的小说来到现实——基于stable diffusion的小说插画生成
- 微信公众号开发笔记(八)发送图片消息
- python爬表情包_【从零开始写爬虫一】批量下载表情包
- QDateTime类
- 认认真真推荐 10 个优质自学平台
- 外贸人如何从SiteGround购买建站外贸主机
- MySQL给查询结果添加序号列的书写格式
- python学习笔记(BMR计算器)
- ringbuff进阶 evbuffer
- 2019年大数据技术与应用专业24个省份130所学校招生
- Python写个小游戏:蛇棋(下)
- 如何提取谷歌地球的高程点为XYZ文本
- 服务主机DCOM占用cpu过高
- Entity Framework链接数据库设置