[英]Web API 405 Method Not Allowed In Remote
以下是我的动作:
public IHttpActionResult PutUnit(int id, Unit unit)
{
if (!ModelState.IsValid)
return BadRequest(ModelState);
if (id != unit.UnitId)
return BadRequest();
db.Entry(unit).State = EntityState.Modified;
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
if (!UnitExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return StatusCode(HttpStatusCode.NoContent);
}
以下是我得到的答复:
Date: Tue, 19 Aug 2014 10:30:31 GMT
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Allow: GET, HEAD, OPTIONS, TRACE
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Content-Type: text/html
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type
Content-Length: 1293
我的控制器的所有操作在本地都可以正常工作,但是一旦我在远程服务器上部署了相同的项目。 我无法仅访问控制器的PUT
和DELETE
操作,而是收到405/Method Not Allowed
错误。 web.config
和webapiconfig.cs
相同,并使用默认结构。 有什么建议吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.