Rupesh
Rupesh

Reputation: 101

C# MVC Project throws HTTP Error 404.7 - Not Found The request filtering module is configured to deny the file extension

The MVC project has a Startup.cs file in its root. When i run the project it throws

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

web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="Startup.cs" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

I added the following lines of config inside system.webserver tag - but there is no change:

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

Upvotes: 1

Views: 505

Answers (1)

user7217806
user7217806

Reputation: 2119

You do not need to add any defaultDocuments, and should not use cs files there.

If you are using the default route, it is sufficient to add a Home controller with a Index action, which will be called by default. You can adapt the default route to use another controller/action.

Upvotes: 1

Related Questions