Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 只有在端点上使用相对地址时,才能获取http 400错误请求_C#_Wcf - Fatal编程技术网

C# 只有在端点上使用相对地址时,才能获取http 400错误请求

C# 只有在端点上使用相对地址时,才能获取http 400错误请求,c#,wcf,C#,Wcf,我得到一个: http 400错误请求 仅当我在端点上使用相对地址时出错 如果我从地址中删除“basic”,我可以毫无问题地查看WSDL定义: http://localhost:8001/Test/ 但只要我添加“基本”并打开浏览器并键入: http://localhost:8001/Test/basic 我得到了错误 这是我的配置: <system.serviceModel> <services> <service name="HostCo

我得到一个:

http 400错误请求

仅当我在端点上使用相对地址时出错

如果我从地址中删除“basic”,我可以毫无问题地查看WSDL定义:

http://localhost:8001/Test/
但只要我添加“基本”并打开浏览器并键入:

http://localhost:8001/Test/basic
我得到了错误

这是我的配置:

<system.serviceModel>
    <services>
      <service name="HostConsole.ContactService" 
               behaviorConfiguration="ServiceBehavior" >
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8001/Test/"/>
          </baseAddresses>          
        </host>
        <endpoint address="basic" 
                  binding="basicHttpBinding" 
                  contract="HostConsole.IContactService">
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

带有“basic”的地址字段位于完整服务URL之后。我在这里没有看到单独的服务激活,也没有看到.svc文件的名称,但它类似于
http://localhost:8001/Test/YourService.svc/basic

谢谢你的回复,我不是IIS主机,所以我没有*.svc文件。
ServiceHost host = new ServiceHost(typeof(ContactService));

try {
    host.Open();

    foreach (ServiceEndpoint se in host.Description.Endpoints) {
        Console.WriteLine(string.Format(
            "Address: {0}",
            se.Address.Uri.AbsoluteUri));
    }

    Console.WriteLine("Enter to close");
    Console.ReadLine();

    host.Close();
}
catch (Exception ex) {
    host.Abort();
    Console.WriteLine(ex.Message);
    Console.ReadLine();
}