Using System.Web.Http on mac os x

拥有回忆 提交于 2019-12-12 10:22:46

问题


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:


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"



来源:https://stackoverflow.com/questions/30743919/using-system-web-http-on-mac-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!