HttpRequestMessage could not be found, but a link to System.Net.Http

I have a new .Net 4.5.2 (verified that this is the target platform). Web API Application (in VS 2015). I referenced System.Net.Http, and, as you see, version 4.0.0.0:

system.Net.Http reference properties

In my Filter / Attribute, I try to reference HttpRequestMessagewhich is in the namespace System.Net.Http(I have the correct use at the top of my file), but I get a message saying

The type "HttpRequestMessage" is defined in an assembly that is not referenced. You must add a reference to the assembly 'System.Net.Http, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a'

when trying to reference HttpRequestMessage

And although I cannot reference this class, I can go to it in Object Exploerer (I assume that it uses an XML file with the same name next to the .dll).

I tried (edited: like a normal VS restart and rebuild, etc.):

  • Removing and re-adding a link (both from the Framework and from the Extension - although I'm sure it was a version of the Framework, I was getting desparate)
  • Installing from Nuget and linking to the version in my local package folder, which apparently just goes back to the system-wide version by default.
  • Reinstalling all my dependencies in Nuget PM with: update-package -reinstall -ignoreDependencies
  • Adding an assembly manually to web.config Adding an assembly manually to a .csproj file

[Edit: Solution:

, VS Web API ( ), , . "", Filter, , lo-and-behold HttpRequestMessage. ( App_Code), . , , , System.Net.Http, , , , , , - . . , , , .]

+4
2

, RouteConstraints App_Code. .

+1

-, -, App_Code - , "" ( , "" " " ), Intellisense "", : . Vishel Joshi.

0

Source: https://habr.com/ru/post/1607201/


All Articles