Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a relative path in ASP.NET MVC

How do you calculate a relative path in ASP.NET MVC?

like image 278
andrew Sullivan Avatar asked Dec 02 '22 04:12

andrew Sullivan


1 Answers

also, if you want the relative path inside your controller, you can use:

string pathName = VirtualPathUtility.ToAbsolute(string.Format(@"~/images/PhotoAlbum/{0}/", propertyId));

or:

string pathName = VirtualPathUtility.ToAppRelative(string.Format(@"~/images/PhotoAlbum/{0}/", propertyId));

depending on your need..

hope this helps.

like image 192
jim tollan Avatar answered Mar 23 '23 22:03

jim tollan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!