本文介绍了找不到与请求URI匹配的HTTP资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的ajax调用,它正在调用GetFileContents:

  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,我都会收到一条错误消息

Whenever titleClick gets instantiated I get an error saying

.我在此Service文件中还有其他控制器,可以很好地调用它.我猜我的语法有问题吗?请帮助,我在这里四处张望,但找不到与我的问题有关的特定内容.谢谢!

. I have other controllers in this Service file which I am able to call perfectly fine. I am guessing something wrong with my syntax ? Please help , I looked around here but could not find something specific to my problem. Thanks!

推荐答案

更改您的JS参数DocumentId以匹配您的控制器ID.

Change your JS param DocumentId to match your controller id.

$.ajax({
  type: "GET",
  //"Document/GetByReview?reviewId=" + that.selectedReview.ReviewId;
  url: constants.serviceUrl + "Document/GetFileContents?id=" + docId,
  contentType: "application/json; charset=utf8",
});

这篇关于找不到与请求URI匹配的HTTP资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-24 05:33