在阅读了几个类似的问题并尝试他们的解决方案后,没有人能为我工作。
我的控制器与get
,post
和put
的路径相同。 3完全本地工作,但部署在服务器上,PUT
给我返回404。
这是控制器操作的代码。所有这些都是混淆的,因为它的代码是我为客户开发的
[Route("objects/")]
[Route("objects/{token}/")]
[Route("controller/objects/")]
[Route("controller/objects/{token}/")]
[ActionName("objects")]
[HttpGet()]
public List<Object> Objects(string token)
{
// Works perfectly, both local and deployed
}
[Route("objects/")]
[Route("objects/{token}/")]
[Route("controller/objects/")]
[Route("controller/objects/{token}/")]
[ActionName("objects")]
[HttpPost()]
public string InsertObjects([FromUri]string token, [FromBody]Newtonsoft.Json.Linq.JObject obj)
{
// Returns a 500, but at least its called. Not used for the moment
}
[Route("objects/")]
[Route("controller/objects/")]
[ActionName("objects")]
[HttpPut()]
public string RemoveObject([FromBody]Newtonsoft.Json.Linq.JObject obj)
{
// Returns a 404 deployed on server. Works perfectly locally
// If you wonder why put instead of delete for a remove action, its because we don't delete from the db, just set a field value to false
}
我一直在阅读,可能是PUT处理程序不在配置上,但这是当前的处理程序
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
如您所见,verb
设置为*
,这意味着它还应该考虑PUT
和DELETE
,对吧?