我很感激任何帮助,因为该网站应该今晚上线!
我有一个带有Delete方法的web api控制器.该方法在运行IIS Express(Windows 8)的本地计算机上执行正常,但只要我将其部署到实时IIS服务器(Windows Server 2008 R2),它就会停止工作并抛出以下错误消息:
HTTP错误405.0 - 不允许的方法由于使用了无效的方法(HTTP Verb),无法显示您要查找的页面
我在网上寻找解决方案,并实施了最合理的解决方案.我的网络配置包含以下设置:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
我也试图在IIS中更改处理程序映射和请求筛选无济于事.请注意,IIS中的WebDAV创作规则似乎已被禁用.
任何想法将不胜感激谢谢.
大家好,我需要帮助..我总是收到 405 Method Not Allowed
我正在使用 Asp.Net Core Web 应用程序 3.1,我的 HttpGet 没有问题,但当我使用 HttpPost 时,它总是返回 405 状态代码
这是我的控制器
[Route("api/[controller]")]
[ApiController]
public class ExamController : ControllerBase
{
[HttpPost("PostValue")]
public ActionResult<HttpResponseMessage> PostInfo([FromBody] PersonalInfo info)
{
string json = JsonConvert.SerializeObject(info);
HttpClient client = new HttpClient();
var response = client.PostAsync("https://sampleapi/receive", new StringContent(json, Encoding.UTF8, "application/json"));
if (response.IsFaulted)
return BadRequest(response);
return Ok(response);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的创业班
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) …Run Code Online (Sandbox Code Playgroud)