木木的布劳格

  • 首页
  • 学无止尽
  • 愉悦生活
  • 中医
  • 软件
  • 单反摄影
  • 收藏的软件
  • About Me
木木的布劳格
记录生活点滴的静默博客
  1. 首页
  2. 学无止尽
  3. 正文

服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF 解决方案

16 12 月, 2013 2218点热度 15人点赞 0条评论

2013-12-16_062702

Better Life

显示行号 复制代码 ? 处理『服务器提交了协议冲突』
  1. #region 处理『服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF』
    
  2.         //需引用 using System.Reflection;
    
  3.         public static bool SetAllowUnsafeHeaderParsing()
    
  4.         {
    
  5.             //Get the assembly that contains the internal class
    
  6.             Assembly aNetAssembly = Assembly.GetAssembly(
    
  7.             typeof(System.Net.Configuration.SettingsSection));
    
  8.             if (aNetAssembly != null)
    
  9.             {
    
  10.                 //Use the assembly in order to get the internal type for 
    
  11.                 // the internal class
    
  12.                 Type aSettingsType = aNetAssembly.GetType(
    
  13.                 "System.Net.Configuration.SettingsSectionInternal");
    
  14.                 if (aSettingsType != null)
    
  15.                 {
    
  16.                     //Use the internal static property to get an instance 
    
  17.                     // of the internal settings class. If the static instance 
    
  18.                     // isn't created allready the property will create it for us.
    
  19.                     object anInstance = aSettingsType.InvokeMember("Section",
    
  20.                     BindingFlags.Static | BindingFlags.GetProperty
    
  21.                     | BindingFlags.NonPublic, null, null, new object[] { });
    
  22.                     if (anInstance != null)
    
  23.                     {
    
  24.                         //Locate the private bool field that tells the 
    
  25.                         // framework is unsafe header parsing should be 
    
  26.                         // allowed or not
    
  27.                         FieldInfo aUseUnsafeHeaderParsing = aSettingsType.GetField(
    
  28.                         "useUnsafeHeaderParsing",
    
  29.                         BindingFlags.NonPublic | BindingFlags.Instance);
    
  30.                         if (aUseUnsafeHeaderParsing != null)
    
  31.                         {
    
  32.                             aUseUnsafeHeaderParsing.SetValue(anInstance, true);
    
  33.                             return true;
    
  34.                         }
    
  35.                     }
    
  36.                 }
    
  37.             }
    
  38.             return false;
    
  39.         }
    
  40. 
    
  41.         #endregion
    
  42. 
    

转载自:http://blog.sina.com.cn/s/blog_6051c4e801010dnt.html

本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: 服务器提交了协议冲突,Section=ResponseHeader,Detail=CR,后面必须是 LF, 解决方案
最后更新:19 6 月, 2017

chat

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复
标签聚合
c# 序列号 激活 wm PHP win10 python CENTOS
广告
分类
  • C sharp
  • Delphi
  • Python
  • VPS
  • 中医
  • 伤寒论
  • 其他
  • 单反摄影
  • 学无止尽
  • 工作相关
  • 愉悦生活
  • 未分类
  • 软件

COPYRIGHT © 2023 木木的布劳格. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang