托管在共享主机上时,Web API删除并无法正常工作 [英] Web API delete and put not working when hosted on shared hosting
问题描述
我担心的是,我的返回JSON的web-api项目在本地运行良好,但是在共享主机上托管时
My concern is that my web-api project that returns JSON works, very well locally, but when hosted on shared hosting
我已经添加了这个
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/>
</modules>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/>
</modules>
还检查了本文中提到的设置,并且一切都已存在.
Checked the setting mentioned in this article as well and it was all there.
删除和放置- http://api.antheminfotech.net/api/employees/23 -500错误
DELETE and PUT - http://api.antheminfotech.net/api/employees/23 - 500 Error
我已经厌倦了很多事情,我对Web-api还是有点陌生,所以也许我错过了一些东西...或者我是否需要VPS托管才能具有必需的访问权限....
I have tired a lot of things, I am bit new to web-api so maybe I am missing somthing... or do i need a VPS hosting to have required access....
顺便说一句,我正在使用Enitiy框架,并基于EF模型为此创建了一个自动生成的控制器.
BTW I am using enitiy framework and creating a autogenerated controllers for this, based on EF models.
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
推荐答案
该探针似乎与共享主机有关,它们无法绕过安全性并提供正确的访问权限.它在那里似乎运转良好.
It seems that the probelm lied with the shared hosting, they where not able to bypass security and give the correct access.. I moved the API to a VPS and It worked seemlessly there.
这篇关于托管在共享主机上时,Web API删除并无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!