4

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

0

2 Answers 2

14

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.

Sign up to request clarification or add additional context in comments.

Comments

4

To include an image or a script or any other file this is the code:

<script src="<%= Url.Content("~/Scripts/tiny_mce/jquery.tinymce.js") %>" type="text/javascript"></script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.