Asp.net mvc 如何在razor中拆分url路径

Asp.net mvc 如何在razor中拆分url路径,asp.net-mvc,asp.net-mvc-3,razor,url-rewriting,split,Asp.net Mvc,Asp.net Mvc 3,Razor,Url Rewriting,Split,我得到的图像url路径如下: http://localhost:3810/images/test.png 我想要的是分割路径,然后只获取路径,例如:/images/test.png 用剃刀 任何帮助或建议都将不胜感激您可以像这样使用Uri类: @{ Uri uri = new Uri("http://localhost:3810/content/images/thumbs/0000019.png"); string path = uri.PathAndQuery; } 路径变

我得到的图像url路径如下:

http://localhost:3810/images/test.png
我想要的是分割路径,然后只获取路径,例如:/images/test.png 用剃刀


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

您可以像这样使用Uri类:

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

您正在寻找一个新的路径吗?