2日間立ち往生しているので、助けが必要です。私はグーグルで検索しましたが、正しい解決策を見つけることができませんでした。
修正方法、またはデバッグを改善する方法について誰か助けてもらえますか?
ローカルホストに送信されているもの
POST /Service1.svc/addt HTTP/1.1
Content-Type: application/json
Host: localhost.:13309
Content-Length: 25
Expect: 100-continue
Connection: Keep-Alive
応答 (フィドラーで表示)
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML>
GET 操作は正常に機能しているので、POST 操作が間違っているように感じます。
Web.config および Post 操作の下の情報について
string requestData = "{\"ID\":1,\"Make\":\"Ferrari\"}";
byte[] data = Encoding.UTF8.GetBytes(requestData);
request = (HttpWebRequest)WebRequest.Create("http://localhost.:13309/Service1.svc/addt");
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = data.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(data, 0, data.Length);
dataStream.Close();
WebResponse webr = request.GetResponse();
<system.web>
<compilation debug="true" targetFramework="4.5" />
<customErrors mode="Off"/>
<httpRuntime requestPathInvalidCharacters="<,>,*,%,:,\,?" maxRequestLength="2097151" />
</system.web>
<system.serviceModel>
<services>
<service name="FinanceService.Service1" behaviorConfiguration="ServiceBehaviour">
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address ="" binding="webHttpBinding" contract="FinanceService.IService1" behaviorConfiguration="web">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>