在Mac OS X上使用System.Web.Http [英] Using System.Web.Http on mac os x

查看:107
本文介绍了在Mac OS X上使用System.Web.Http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Mac的新手,但不是.Net.我在玩Visual Studio Code.我安装了Brew,并用它来获取yogrunt-cligenerator-aspnetdnvm以及教程说要获取的所有内容.我用yo创建了一个项目支架,我要做的第一件事是添加一个从

看来我应该打开project.json并添加如下内容:

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

在依赖项下.我不知道要使用哪个版本号,所以我尝试了最新",但是无论何时我运行dnu update,都说找不到System.Web.Http.

在哪里可以找到有关添加对Visual Studio Code的引用的信息?如何引用特定的DLL(对我来说尤其是System.Web.Http)以及要引用什么版本?

解决方案

您的问题的答案分为几个部分.

ApiController

首先,ASP.NET MVC 6将WebAPI和MVC 5控制器统一为一个.如果愿意,您仍然可以使用ApiController,但是您将需要Microsoft.AspNet.Mvc.WebApiCompatShim.

没有System.Web.Net

第二, Matt DeKrey 是正确的. System.Web.Http不是.NET核心库.根据您尝试执行的操作,您可能正在寻找System.Web.Http.Common.

查找程序包版本

使用VS Code时,您应该会看到自动完成功能,它将为您推荐版本号.在这种情况下,您可以使用:

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

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?

解决方案

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"

这篇关于在Mac OS X上使用System.Web.Http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆