0
突然我收到一個錯誤'Method not allowed。'。當從一個HTML表單調用WCF REST POST服務時(如前所述,它在開發,UAT,生產環境中工作較早,但現在失敗)。WCF REST POST服務 - 當從HTML調用時不允許使用方法
什麼可能導致此問題?以及可能的修復方法是什麼?
<form action="http://localhost:8750/MyService/MyEmailService/RecordResponse" method="post" runat="server">
<div align="left">
<input type="hidden" name="userid" value="abc">
<input type="hidden" name="itemid" value="625">
<select name="response">
<option value="Approved">Approve</option>
<option value="Rejected">Reject</option>
</select>
<textarea cols="40" rows="5" name="comment">Add comments here</textarea>
<input type="Submit" value="Submit">
</div>
</form>
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class MyEmailService: IMyEmailService, ISessionAwareService
{
[OperationContract]
[WebInvoke(UriTemplate = "/RecordResponse", Method = "POST")]
public void RecordResponse(Stream stream)
{
// My business logic
}
}
的配置如下:
<endpointBehaviors>
<behavior name="webby">
<webHttp helpEnabled="true"/>
</behavior>
<service name="CTRL.Server.CommandHandlerService.EmailHandlerService">
<endpoint address="http://localhost:8750/MyService/MyEmailService"
binding="webHttpBinding"
contract="MyService.ServiceContracts.IEmailService"
behaviorConfiguration="webby"/>
<webHttpBinding>
<binding name="secure">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</webHttpBinding>