为什么servicestack返回404 Handler for Request not found错误?

时间:2013-01-10 07:09:37

标签: asp.net web-services c#-4.0 servicestack

我在.net 4.5中创建了一个基于Rest的服务,并在IIS7中托管了它。

我能够使用HTTP WebRequest(GET,POST)来获取服务并获得响应,但是当通过ServiceStack命中时,我收到以下错误消息,

enter image description here

在服务堆栈中点击API的代码是,

    IServiceClient serviceClient = new XmlServiceClient("http://localhost/ServerAccessManagerAPI/events");
    var response = serviceClient.Send(request); 

我在服务配置文件

中包含以下行
  <location>
    <system.web>
      <httpHandlers>
        <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
      </httpHandlers>
    </system.web>

    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true" />
      <validation validateIntegratedModeConfiguration="false" />
      <handlers>
        <add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
        <remove name="WebDAVModule" />
      </handlers>
    </system.webServer>

  </location>

有人可以帮我吗? 感谢。

1 个答案:

答案 0 :(得分:0)

ServiceStack ServiceClients接受 BaseUri ,其中 Base Uri 应该是所有ServiceStack服务,而不是特定网址的网址。请尝试改为:

var serviceClient = new XmlServiceClient("http://localhost/ServerAccessManagerAPI/");
var response = serviceClient.Send(request);