mattbloke
mattbloke

Reputation: 1166

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

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?

Upvotes: 27

Views: 126667

Answers (5)

HamidKhan
HamidKhan

Reputation: 564

To allow the required extensions: On the server hosting testserver, start IIS Manager.

In the left pane, under Connections, expand the Sites drop-down and select the mytestserver website.

In the middle Home pane, select Request Filtering.

In the right pane, under Actions, select Allow Filename extensions.

Add extension for eg.- .mdb

Restart IIS manager

Upvotes: 0

Juls
Juls

Reputation: 688

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" />

Upvotes: 0

user8593314
user8593314

Reputation:

You can resolve by adding:

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

to your Web.Config file

Upvotes: 3

mattbloke
mattbloke

Reputation: 1166

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

Upvotes: 40

aditya
aditya

Reputation: 342

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

Upvotes: 1

Related Questions