【发布时间】:2023-03-14 03:45:02
【问题描述】:
我使用 x-editable 并尝试将日期发布到我的控制器
x-可编辑的代码是
<span class="editable editable-click" title="" data-type="select" data-value="1" data-pk="2" data-url="http://localhost:58250/api/updateeffortitems/save" data-title="Work group" data-source="[{ value: 1, text: 'Project'},{ value: 2, text: 'Service'},{ value: 3, text: 'Process'},{ value: 4, text: 'Training'},{ value: 5, text: 'Others'}]" data-original-title="Project">Project</span>
现在我尝试访问以下控制器中发布的数据
Public Class UpdateEffortItemsController
Inherits ApiController
Public Function save(pk As Integer, value As String) As String
Dim db As New RA_SQLEntities
Dim row As Ra_activity_log
row = db.Ra_activity_log.Where(Function(XX) XX.Activity_log_key = pk).SingleOrDefault()
row.Comment = value
db.SaveChanges()
Return "done"
End Function
End Class
我收到以下错误
{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:58250/api/updateeffortitems/save'.","MessageDetail":"No action was found on the controller 'UpdateEffortItems' that matches the request."}
我知道控制器函数必须有 2 个参数,而 ajax url 没有这些参数.. 但是当我将参数添加到 ajax url 时,这意味着参数等于静态值并且无法更改
我该怎么办?
【问题讨论】:
-
你需要在方法中添加上面的[HttpPost]。所以它可以调用发布请求。
标签: jquery asp.net-web-api asp.net-ajax x-editable