【发布时间】:2016-04-12 15:01:49
【问题描述】:
据我所知我已经模仿了this post 和this post 的已接受 解决方案。除非我是盲人(我希望我现在是盲人),否则我非常简单的 WCF 服务有一个一尘不染的app.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="RESTBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="Vert.Host.VertService.RSVPService">
<endpoint
address="/RSVP"
binding="webHttpBinding"
contract="Vert.Host.VertService.IRSVP"
behaviorConfiguration="RESTBehavior" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Vert" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
这是相应的服务合同和实施:
namespace Vert.Host.VertService
{
[ServiceContract]
public interface IRSVP
{
[OperationContract]
bool Attending();
[OperationContract]
bool NotAttending();
}
public class RSVPService : IRSVP
{
public bool Attending()
return true;
public bool NotAttending()
return true;
}
}
我通过控制台应用托管所有内容:
class Program
{
public static void Main()
{
// Create a ServiceHost
using (ServiceHost serviceHost = new ServiceHost(typeof(RSVPService)))
{
serviceHost.Open();
// The service can now be accessed.
Console.ReadLine();
}
}
}
我想要做的就是让这个小服务站起来,但我不能用http://localhost:8080/Vert/RSVP/Attending 到达这个端点。我仍然收到405 Method not allowed 作为响应。我正在使用 Visual Studio Community 2015,IIS10,目标是 .NET 4.6
我从建议中尝试过的事情:
- 我为我的服务提供了一个明确命名的行为。不走运。
我错过了什么?
【问题讨论】:
标签: c# wcf app-config