网页API 405不允许的方法在远程 [英] Web API 405 Method Not Allowed In Remote
本文介绍了网页API 405不允许的方法在远程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我的一个动作:
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);
}
以下是我得到的回应:
Following is the response I get:
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
和删除
我的控制器行动,而不是拿到了 405 /法不允许
错误。 的web.config
和 webapiconfig.cs
相同,并使用默认结构。任何建议吗?
All actions of my controller works fine locally but once I deployed the same project on a remote server. I could not access only PUT
and DELETE
actions of my controller instead got the 405/Method Not Allowed
error. web.config
and webapiconfig.cs
are same and using the default structure. Any suggestion please?
推荐答案
在看看<一个href=\"http://blogs.msdn.com/b/joseph_fultz/archive/2009/07/23/enabling-the-put-verb-with-handlers-and-iis-7-0.aspx\"相对=nofollow>启用PUT动词与处理程序和IIS 7.0
这篇关于网页API 405不允许的方法在远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文