8
我試圖從一個ASPX頁面調用WCF Web服務,像這樣調用WCF服務:
var payload = {
applicationKey: 40868578
};
$.ajax({
url: "/Services/AjaxSupportService.svc/ReNotify",
type: "POST",
data: JSON.stringify(payload),
contentType: "application/json",
dataType: "json"
});
否則會導致Web服務器返回錯誤415 Unsupported Media Type
。我敢肯定,這是一個配置問題,其定義如下WCF服務:
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json)]
void ReNotify(int applicationKey);
有在web.config
文件中沒有條目,假設服務使用的默認配置。