1

I have got image url path like :

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

What I am looking is to split the path and just get the path for instance : /images/test.png using razor.

Any help or suggestion will be appreciated

Mr A
  • 6,448
  • 25
  • 83
  • 137
  • are you looking for a [site root relative path](http://stackoverflow.com/questions/3164/asp-net-absolute-path-back-to-web-relative-path)? – Maciej Oct 19 '11 at 15:22

1 Answers1

3

You can use the Uri class like this:

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

The path variable will be /content/images/thumbs/0000019.png.

goenning
  • 6,514
  • 1
  • 35
  • 42