Using System.Web.Http on mac os x

1.9k views Asked by At

I'm new to mac but not .Net. I'm playing around with Visual Studio Code. I installed Brew and used it to get yo, grunt-cli, generator-aspnet, dnvm, and everything the tutorials say to get. I created a project scaffold with yo and the first thing I want to do is add a Controller that inherits from ApiController but I can't seem to find a way to "Add a reference" like I would in Visual Studio proper.

It looks like I should open project.json and add something like this:

"System.Web.Http": "<some version number>"

under dependencies. I don't know what version number to use, so I tried "latest" but anytime I run dnu update it says System.Web.Http can't be found.

Where can I find information about adding references to Visual Studio Code? How to reference particular DLLs (specifically System.Web.Http for me) and what versions to reference?

1

There are 1 answers

0
natemcmaster On

The answer to your question has several parts.

ApiController

First of all, ASP.NET MVC 6 unifies WebAPI and MVC 5 controllers into one. You can still use ApiController if you want to, but you will need Microsoft.AspNet.Mvc.WebApiCompatShim.

There is no System.Web.Net

Second, Matt DeKrey is correct. System.Web.Http is not a .NET core library. Depending on what you are trying to do, you may be looking for System.Web.Http.Common.

Finding package version

When using VS Code, you should be seeing autocomplete that will recommend version numbers for you. In this case you could use:

"System.Web.Http.Common": "4.0.20216.16343"

screen shot of autocomplete version numbers