在WCF项目中设置Web API [英] Setting up Web API within WCF Project

查看:80
本文介绍了在WCF项目中设置Web API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的实践"问题.对我们项目的体系结构的要求是使用WCF项目中的所有MVC优点(如果可能)设置Web API.这意味着WCF和Web API Web服务将在一个项目中彼此站在一起.

I have a little bit of a "strange practise" question. The requirement on an architecture of our project is to setup Web API with (if possible) all MVC goodness within WCF project. That means that WCF and Web API web services would be stood up along each other within one project.

这甚至可行吗?经过一小段时间,我发现即使合并两个项目的Web配置也非常困难.

Is this even doable? I've given it a short go and found that even merging the web configs of two projects is very hard.

感谢您的建议和评论,

雅各布

推荐答案

可能但会丢失MVC优势(这意味着您将无法使用Web服务的内置自动在线文档)

It is possible but with losing the MVC goodness (that means that you will not be able to use for example the built in automatic online documentation for your web services).

只需通过NuGet安装Web API,然后在global.asax中注册您的路由.创建您的api控制器,一切都会很好.

Just install Web API through NuGet and then register your route in global.asax. Create your api controller and it should be all good.

编辑01.02.2017:

这不再成立.由于Microsoft的方法是合并MVC和Web API控制器.现在,任何事情都是可能的.

This is no longer true. Since Microsoft approach was to merge MVC and Web API controller. Now anything is possible.

这篇关于在WCF项目中设置Web API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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