HttpWebRequest in c# do not work with .net 4.5

后端 未结 4 1452
无人共我
无人共我 2021-01-13 01:48

i\'m working on an c# project that send a xml to a server and receives a xml as response.
With .Net Framework 4.0 installed that works fine.
With .Net Framework 4.5

相关标签:
4条回答
  • 2021-01-13 02:27

    Strange there wasn't a serious answer posted already...

    HttpWebRequest has been made obsolete in .NET 4.5 and later versions so it will not compile which is noted on the msdn site

    This is why Jammer is saying to use HttpClient as a replacement since it seems to be the replacement microsoft has made for it.

    Looks like it will be an effort to change your code but I'd say it's all for the best

    0 讨论(0)
  • 2021-01-13 02:38

    As previously mentioned, HttpWebRequest is obsolete now. Have you tried HttpRequest? Found here: https://msdn.microsoft.com/en-us/library/system.web.httprequest(v=vs.110).aspx

    0 讨论(0)
  • 2021-01-13 02:42

    I had the same strange problem in IdnEquivalent. The problem persisted when I had Fiddler web debugger launched during my debug session. After I shut it down the problem disappeared.

    0 讨论(0)
  • 2021-01-13 02:45

    To be honest as you are now targeting .NET 4.5 I would have a look into using HttpClient instead of HttpWebRequest.

    HttpClient

    0 讨论(0)
提交回复
热议问题