4

I have request filtering enabled and "Allow unlisted file name extensions" is set to false. When requesting any normal path, including "http://localhost" I get a 404.7 error - "The request filtering module is configured to deny the file extension."

If I set "Allow unlisted file name extensions" to true then the site works fine.

I know that "http://localhost/" maps to Views/Homes/Index.cshtml" and .cshtml is explicitly allowed.

I am trying to figure out which file extension is causing the issue but can't find anything in the logs. I have all 55 "default" file types set to allow.

2 Answers 2

8

Try just "." as the file extension. This seems to work on a Windows 2008 R2 SP1 box with ASP.NET 4.

I haven't seen this documented anywhere, but it follows the same rule as the Handler Mappings for extensionless URLs that were introduced in ASP.NET 4 / W2K8 R2 SP1 (see Meaning of path attribute on handlers in web.config question).

2
  • Anyone know if allowing "." as the file extension is seen as a wildcard?
    – HiTech
    Oct 11, 2019 at 21:52
  • No it's not a wild card per se. It basically means, any request with OUT a file extension.
    – PilotBob
    Aug 16, 2021 at 19:52
1

I think what you're trying to do is not possible.

MVC doesn't use file extensions. By setting "Allow unlisted file name extensions" to false, you limit IIS to just serve the extensions listed. As you can't add an 'extensionless extension' IIS denies the request.

In other words, you need "Allow unlisted file name extensions" set to true if you want to use MVC.

You don't have to allow '.cshtml' you can even deny access to it, MVC still works, because the view files are not served directly by IIS by read by MVC and then send via IIS to the client.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .