【问题标题】:How to split url path in razor如何在剃刀中拆分url路径
【发布时间】:2011-12-11 00:50:40
【问题描述】:

我有像这样的图片 url 路径:

http://localhost:3810/images/test.png

我正在寻找的是拆分路径并获取路径,例如:/images/test.png 使用剃须刀。

任何帮助或建议将不胜感激

【问题讨论】:

标签: asp.net-mvc asp.net-mvc-3 razor url-rewriting split


【解决方案1】:

你可以像这样使用 Uri 类:

@{
    Uri uri = new Uri("http://localhost:3810/content/images/thumbs/0000019.png");
    string path = uri.PathAndQuery;
}

path 变量将是 /content/images/thumbs/0000019.png

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-24
    • 2016-02-02
    • 1970-01-01
    • 2012-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多