• c# mvc webapi的put报405错误


    程序在本机调试可正常修改,本机是iis11

    放到服务器上,报错了:405。服务器iis7.0

    返回的错误页面:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
    <title>405 - 不允许用于访问此页的 HTTP 谓词。</title>
    <style type="text/css">
    <!--
    body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
    fieldset{padding:0 15px 10px 15px;} 
    h1{font-size:2.4em;margin:0;color:#FFF;}
    h2{font-size:1.7em;margin:0;color:#CC0000;} 
    h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
    #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
    background-color:#555555;}
    #content{margin:0 0 0 2%;position:relative;}
    .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
    -->
    </style>
    </head>
    <body>
    <div id="header"><h1>服务器错误</h1></div>
    <div id="content">
     <div class="content-container"><fieldset>
      <h2>405 - 不允许用于访问此页的 HTTP 谓词。</h2>
      <h3>您要查找的页面无法显示,因为尝试访问时使用了无效方法(HTTP 谓词)。</h3>
     </fieldset></div>
    </div>
    </body>
    </html>

    这个郁闷呐,最后修改web.config配置文件解决了

    <handlers>
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
          <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
          <remove name="WebDAV" />
          <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFrameworkv4.0.30319aspnet_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.NETFramework64v4.0.30319aspnet_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>
        <modules>
          <remove name="WebDAVModule" />
        </modules>

     也就是添加一条:

    <remove name="WebDAV" />
     <modules>
          <remove name="WebDAVModule" />
        </modules>
    解决的,暂时还不清楚为什么这个搞

    https://stackoverflow.com/questions/12440277/how-do-i-enable-http-put-and-delete-for-asp-net-mvc-in-iis
  • 相关阅读:
    软件项目成员的业绩考核
    COM, COM+ and .NET 程序集的区别
    .Net 应用框架设计系列(二)
    怎样在Web开发中完美控制IE标题栏
    影楼系统
    PHP读取ACCESS数据到MYSQL
    简单分享apache 封 IP 的方法
    详解Apache下.htaccess文件常用配置
    fleaphp常用方法分页之Pager
    php遍历文件夹读取文件夹中图片并分页显示图片
  • 原文地址:https://www.cnblogs.com/mantishell/p/12056423.html
Copyright © 2020-2023  润新知