Daniel Plaisted
Daniel Plaisted

Reputation: 16744

How to have a route in ASP.NET MVC with a file extension that would be blocked by request filtering

I have a route that basically looks like this:

Foo/{id}/Files/{*path}

I want it to match a URL such as:

http://mysite/Foo/Bar/Files/Baz.cs

However, I get an HTTP 404.7 error that says "The request filtering module is configured to deny the file extension." I can remove the file extension from request filtering by modifying web.config, but I don't want my source code to be viewable. How should I set this up?

Upvotes: 3

Views: 789

Answers (2)

linkerro
linkerro

Reputation: 5468

If the paths to the files don't match with the urls you want to have than you can do the following:

  1. mark the folder where you keep your source files as denied for everyone in the web.config (example for the /SourceCode dir)

  2. allow the .cs extension in the request filtering module

Upvotes: 0

tpeczek
tpeczek

Reputation: 24125

The only way you might have possibility to get it working is through relaxedUrlToFileSystemMapping setting in ASP.NET 4.0. You can read more here:

Upvotes: 1

Related Questions