WebRequest / WebClient:必须使用适当的属性问题修改此标头 [英] WebRequest/WebClient: This header must be modified using the appropriate property problem

查看:628
本文介绍了WebRequest / WebClient:必须使用适当的属性问题修改此标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用WebRequest或WebClient做一个以编程方式发起的帖子(并不重要)


当我尝试将标题放入任何instanciated对象,我得到错误:
此标头必须使用适当的属性问题进行修改


< p dir = ltr align = left>我已经阅读了微软VS2005 / 2008开发人员的几篇帖子。他们声称修复了在WebRequest类中使用一些受限制的标头时引起的问题,该类抛出了" 此标头必须使用适当的属性修改 "错误:


1-使用WebClient而不是webrequest ...但是如果使用了重新定义的标题,webclient仍会触发该异常。


<带有VS2008的pdir = ltr align = left> 2- dotnet 3.5 应该有一个新的WebRequest方法叫做:AddWithoutValidate() - 根据MS--允许向WebRequest添加受限制的头类型....但是VS 2008中不存在该方法。



任何想法或克服这个问题的解决方案??



谢谢

解决方案

您要设置哪个标题?根据错误消息,必须使用HttpWebRequest本身上的相应属性设置某些标头,而不是通过在标头集合中设置值。


I need to do a programmatically originated post using WebRequest or WebClient (doesnt really matter)

When I try to a header into any of the instanciated object, i got the error:
This header must be modified using the appropriate property problem

I have read a couple posts by Microsoft's VS2005/2008 developers. They claim to fix the issue caused when using some restricted headers with the WebRequest class which throw the "This header must be modified using the appropriate property" error :

1- use WebClient instead of webrequest... but webclient still fires that exception if resricted headers are used.

2- dotnet 3.5 with VS2008 should have a new method for WebRequest called: AddWithoutValidate() which --according to MS-- allows the addition of restricted header type to WebRequest.... However that method does not exists in VS 2008.

 

Any ideas or solution for overcoming this problem ??

 

Thanks

解决方案

Which header specifically are you trying to set? Per the error message, some headers must be set using the corresponding property on the HttpWebRequest itself and not by setting a value in the header collection.


这篇关于WebRequest / WebClient:必须使用适当的属性问题修改此标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆