I am having troubles adding web-api 2 to my existing projects due to the inability to reference System.Net.Http.HttpMessageHandler
Relevent code below
global.asax
<%@ Application Language="C#" Inherits="GlobalAsax" %>
global.asax.cs
using System.Web.Http;
using System.Web.Routing;
/// <summary>
/// Summary description for Global
/// </summary>
///
public class GlobalAsax
{
public GlobalAsax()
{
}
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RouteTable.Routes.MapHttpRoute(
name: "Email",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = System.Web.Http.RouteParameter.Optional }
);
}
Using this setup i get the following error Visual Studio 2017\WebSites\FSWeb\App_Code\Global.asax.cs(23,9): error CS0012: The type 'System.Net.Http.HttpMessageHandler' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Doing my own research on this issue, i see that the assimbly must be added to the web.config in the compilation area, however my web.config alreadythat line, so i'm not sure why it won't compile
Web.config
<compilation debug="true" targetFramework="4.0">
<assemblies>
........
<add assembly="System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
</assemblies>
</compilation>
Does anyone have any ideas what i step i am missing in order to compile with web api?
I will link the resources i have already found and attempted (which failed) below.
https://www.c-sharpcorner.com/UploadFile/dacca2/implement-web-api-in-existing-web-form-application/
Where is the Global.asax.cs file? (used to get the namespace into the global asax in a website project)
The type 'HttpRequestMessage' is defined in an assembly that is not referenced