2011-10-19 57 views
1

我有分裂的URL路径图像的URL路径,如:如何剃刀

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

我寻找是分裂的路径和刚刚获得例如路径:使用/images/test.png 剃刀。

任何帮助或建议,可以理解

+0

你在寻找[网站根相对路径](http://stackoverflow.com/questions/3164/asp-net-absolute-path-back-to-web-relative-path)? – Maciej

回答

3

可以使用Uri类是这样的:

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

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