开发者

How to get a relative path in ASP.NET MVC

开发者 https://www.devze.com 2023-01-15 04:34 出处:网络
开发者_Go百科How do you calculate a relative path in ASP.NET MVC?also, if you want the relative path inside your controller, you can use:

开发者_Go百科How do you calculate a relative path in ASP.NET MVC?


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.


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消