【发布时间】:2015-10-22 02:48:28
【问题描述】:
大家好,我正在构建一个网络服务。该服务是在我的本地主机上构建的,所以当我在浏览器中点击 URL 时,例如,http://127.0.0.1/api/MyTest/GetStatus 实际上会响应预期的消息。
<Error>
<Message>
The requested resource does not support http method 'GET'.
</Message>
</Error>
但是,当我尝试使用脚本文件点击它时,它会返回 404 未找到。消息返回为"No HTTP resource was found that matches the request URI 'http://127.0.0.1/api/MyTest/GetStatus'."
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
$.ajax({
url: 'http://127.0.0.1/api/MyTest/GetStatus',
type: 'POST',
contenttype: 'application/json; charset=utf-16',
success: function (msg) {
console.log(msg);
}
});
</script>
我在其他服务上使用的相同脚本,它们都正确响应。有什么想法吗?
【问题讨论】:
标签: .net web-services c#-4.0