文件路径为MVC路由参数 [英] File path as MVC route argument

查看:162
本文介绍了文件路径为MVC路由参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储在多个位置上网址时这样我的应用程序映射资源部分:

Part of my application maps resources stored in a number of locations onto web URLs like this:

http://servername/files/path/to/my/resource/

的资源位置的文件路径仿照其结果可以有嵌套的无限水平。是否有可能兴建匹配该MVC的途径,使我获得了全部的路径传递到我的控制器?无论是作为一个字符串或者可能以字符串PARAMS风格数组。

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.

我想这需要对文件的关键字匹配,其次是某种通配符。虽然我不知道如果MVC支持这一点。

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.

推荐答案

"Files/{*path}"

将得到的路径作为一个字符串。在 * 将其指定为通配符映射,它会消耗掉整个URL后文件/

will get the path as a single string. The * designates it as a wildcard mapping and it will consume the whole URL after "Files/".

这篇关于文件路径为MVC路由参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆