這裏是我的ajax呼叫時,主叫GetFileContents匹配:無HTTP資源發現,請求URI
views.titleClick = function (e) {
var grid = $("#documentsGrid").data("kendoGrid");
var docId = grid._data[0].DocumentId;
$.ajax({
type: "GET",
//"Document/GetByReview?reviewId=" + that.selectedReview.ReviewId;
url: constants.serviceUrl + "Document/GetFileContents?DocumentId=" + docId,
contentType: "application/json; charset=utf8",
})
};
下面是我的控制器GetFileContents
[HttpGet]
public HttpResponseMessage GetFileContents(int id)
{
DataResponseSingle<Document> result = BusinessAccess.GetById(id);
if (result.ResponseType != ResponseType.Success)
{
return CreateHttpResponse(result);
}
if (result.Data == null || result.Data.DocumentData == null)
{
return CreateHttpResponse(ResponseType.NotFound);
}
return CreateStreamContentHttpResponse(result.Data.DocumentData, "application/octet-stream", result.Data.Name);
}
每當titleClick被實例化我收到一個錯誤,說
「{」Message「:」沒有找到與請求URI'http://localhost/Services/HumanResources/api/Document/GetFileContents?DocumentId=4'。「,」MessageDetail「匹配的HTTP資源:」No 在與「 」請求匹配的控制器「文檔」
。我有這個服務文件中的其他控制器,我可以稱之爲完美。我猜我的語法錯了嗎?請幫忙,我環顧四周,但找不到具體的問題。謝謝!
謝謝!!那是什麼錯了呢。我不知道他們必須是同一個名字。現在我做:) –