HTTP Error 404.7 - Not Found The request filtering module is configured to deny the file extension

心不动则不痛 提交于 2019-12-17 16:30:35

问题


I'm trying to configure the default webpage for an IIS 7.5 website.

Request filtering is turned on. However .aspx pages are allowed, I've set default.aspx to be the default page for the website.

If I browse to localhost/default.aspx I get a webpage as expected.

IF I browse to localhost/ I get

HTTP Error 404.7 - Not Found The request filtering module is configured to deny the file extension.

Any ideas?


回答1:


It looks like the request filtering is actually filtering for a blank file name. Therefore you have to add this to the request filtering block in the web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
        <fileExtensions allowUnlisted="true">
          <remove fileExtension="." />
          <add fileExtension="." allowed="true" />
        </fileExtensions>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

It's obvious now, but really I think its a massive gotcha.


More info: IIS 7 Not Serving Files - 404.7 Error




回答2:


You can resolve by adding:

<requestFiltering>
    <fileExtensions allowUnlisted="true">
        <remove fileExtension="." />
        <add fileExtension="." allowed="true" />
    </fileExtensions>
</requestFiltering>

to your Web.Config file




回答3:


You can resolve this by adding the file extension into the request filtering module of IIS.




回答4:


Be sure to remove any PostBackURL="MyPage.aspx" from the button on the page. My guess is that when the postbackurl is included, IIS thinks its getting the page as a file. It rejects the .aspx file type by default. You can see this in the page error.

Bad: Creates a 404.7 (notice the PostBackURL)

<asp:FileUpload runat="server"  ID="uplReplaceFile" ToolTip="Update this file" />

 <asp:Button runat="server" PostBackUrl="MyPage.ascx"  ID="bnHiddenFileUploadListener" OnClick="bnHiddenFileUploadListener_OnClick" />

Good: No error

<asp:FileUpload runat="server"  ID="uplReplaceFile" ToolTip="Update this file" />

 <asp:Button runat="server" ID="bnHiddenFileUploadListener" OnClick="bnHiddenFileUploadListener_OnClick" />


来源:https://stackoverflow.com/questions/13455939/http-error-404-7-not-found-the-request-filtering-module-is-configured-to-deny

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!