最低限度配置REST风格的WCF [英] Bare Minimum Configuration for RESTful WCF
问题描述
最起码我需要把在web.config中得到WCF正与REST是什么?我有我的注释与方法[WebGet],但他们没有得到消息。
What is the bare minimum I need to put in web.config to get WCF working with REST? I have annotated my methods with [WebGet], but they are not getting the message.
推荐答案
我发现,你可以添加以下到的ServiceHost指令中的* .svc文件,它会自动设置的WebHttpBinding和WebHttpBehavior为您提供:
I discovered that you can add the following to the ServiceHost directive in the *.svc file, and it will automatically setup WebHttpBinding and WebHttpBehavior for you:
Factory="System.ServiceModel.Activation.WebServiceHostFactory"
请注意,该命名空间是什么在网络上其他地方提到有一点不同(如的这个MSDN文章)。
Note that the namespace is a little different from what is mentioned elsewhere on the web (such as in this MSDN article).
这样做后,我能够从web.config中删除整个节,一切都还在工作!
After doing this, I was able to delete the entire section from web.config and everything still worked!
这篇关于最低限度配置REST风格的WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!