如何使用 web.config

问题描述

我面临的问题是我的 Windows Server 2008 上的 Plesk IIS 7.5 不接受 DELETE 方法。在对 Stackoverflow 进行一些阅读(例如 How do I enable HTTP PUT and DELETE for ASP.NET MVC in IIS?)后,我尝试将以下内容添加web.config 文件中。

  <modules>
    <remove name="WebDAVModule" />
  </modules>
  <handlers>
    <remove name="WebDAV" />
  </handlers>

但是在我添加之后,我得到了 500 internal server error

这是我的原始 web.config 文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.web>
    <customErrors mode="Off" />
  </system.web>
  <system.webServer>
    <httpErrors errorMode="Detailed" />
        <defaultDocument>
            <files>
                <clear />
                <add value="index.PHP" />
                <add value="default.aspx" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
            </files>
        </defaultDocument>
        <handlers accesspolicy="Read,Execute,Script" />
        <rewrite>
            <rules>
                <rule name="Imported Rule 3" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />                     
                    </conditions>
                    <action type="Rewrite" url="index.PHP/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

这是我修改后的 web.config 文件,它给了我 500 internal server error

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.web>
    <customErrors mode="Off" />
  </system.web>
  <system.webServer>
    <httpErrors errorMode="Detailed" />
        <defaultDocument>
            <files>
                <clear />
                <add value="index.PHP" />
                <add value="default.aspx" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
            </files>
        </defaultDocument>
        <handlers accesspolicy="Read,Script" />
        <rewrite>
            <rules>
                <rule name="Imported Rule 3" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />                     
                    </conditions>
                    <action type="Rewrite" url="index.PHP/{R:1}" />
                </rule>
            </rules>
        </rewrite>
        <modules>
          <remove name="WebDAVModule" />
        </modules>
        <handlers>
          <remove name="WebDAV" />
        </handlers>
          </system.webServer>
</configuration>

如何通过 webDAV 文件禁用 web.config 并让服务器接受 DELETE 方法

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)