ASP.NET MVC routing and file path

I have a controller action that has the same name as the file path. How:

www.example.com/userfiles/path/to/userfile.jpg

Basically, I have a user file controller, and when working with an index, everything happens after the user files / this is the path. At the root of my application there is also a userfiles virtual directory. I want if the directory that follows the userfiles / files (in this case) does not exist in the userfiles virtual directory, then use the index action in userfilesController if the directory exists and then use the path as it is,

This worked flawlessly on my windows xp dev machine with iis 5. But as soon as I moved it to a live server (Windows Server 2003 iis 6), I get a 404 error as if the path does not exist and the userfiles controller index action is not going to.

In the routes file, I:

routes.MapRoute(
    "Userfiles",                                       // Route name
    "userfiles/{*url}",                                // URL with parameters
    new { controller = "Userfiles", action = "Index" } // Parameter defaults
);

What am I missing? He worked so well.

+3
source share
2 answers

So, I found out that my problem was that we turned on the display of wildcard maps for the site, but we also turned it off for certain directories due to performance. I re-enabled the wildcard for the directory in question, and it all started, as in my dev block. Joy!

+1
source

, , -. web.config runAllManagedModulesForAllRequests = "true"

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />

, -.

0

Source: https://habr.com/ru/post/1760812/


All Articles