我担心的是我返回 JSON 的 web-api 项目在本地工作得很好,但是当托管在共享主机上时
我已经添加了这个
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/>
</modules>
也检查了本文中提到的设置,一切都在那里。
删除和放置 - http://api.antheminfotech.net/api/employees/23 - 500 错误
我已经厌倦了很多事情,我对 web-api 有点陌生,所以也许我错过了一些东西......或者我需要一个 VPS 主机来获得所需的访问权限......
顺便说一句,我正在使用 enitiy 框架并为此创建一个自动生成的控制器,基于 EF 模型。
Function PutEmpDetail(ByVal id As Integer, ByVal empdetail As EmpDetail) As HttpResponseMessage
If Not ModelState.IsValid Then
Return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)
End If
If Not id = empdetail.Id Then
Return Request.CreateResponse(HttpStatusCode.BadRequest)
End If
db.Entry(empdetail).State = EntityState.Modified
Try
db.SaveChanges()
Catch ex As DbUpdateConcurrencyException
Return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)
End Try
Return Request.CreateResponse(HttpStatusCode.OK)
End Function
Function DeleteEmpDetail(ByVal id As Integer) As HttpResponseMessage
Dim empdetail As EmpDetail = db.EmpDetails.Find(id)
If IsNothing(empdetail) Then
Return Request.CreateResponse(HttpStatusCode.NotFound)
End If
db.EmpDetails.Remove(empdetail)
Try
db.SaveChanges()
Catch ex As DbUpdateConcurrencyException
Return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)
End Try
Return Request.CreateResponse(HttpStatusCode.OK, empdetail)
End Function