Reputation: 8472
Part of my application maps resources stored in a number of locations onto web URLs like this:
http://servername/files/path/to/my/resource/
The resources location is modelled after file paths and as a result there can be an unlimited level of nesting. Is it possible to construct an MVC route that matches this so that I get the path in its entirety passed into my controller? Either as a single string or possibly as an params style array of strings.
I guess this requires a match on the files keyword, followed by some sort of wildcard. Though I have no idea if MVC supports this.
Upvotes: 18
Views: 8160
Reputation: 25704
For more information on ASP.NET's Routing feature, please see MSDN:
http://msdn.microsoft.com/en-us/library/cc668201.aspx
And for the "catch-all" parameters you want to use, see the section under "Handling a Variable Number of Segments".
Upvotes: 4
Reputation: 32698
A route like
"Files/{*path}"
will get the path as a single string. The *
designates it as a wildcard mapping and it will consume the whole URL after "Files/"
.
Upvotes: 29