简体   繁体   中英

mvc path image in static html page

someone knows how to manage path image in static html? The problem is how to specify the images path INSIDE THE STATIC HTML so to work as online as visual studio localhost

Example : i have a home page and inside some static html page

@Html.Raw(File.ReadAllText(Server.MapPath("~/custom_directory/home/static_page.html")))

INSIDE THE STATIC HTML : 1. if i use relative path : custom_directory/home/img/image1.jpg It works online but it doesnt work in visual studio localhost

  1. if i use / : /custom_directory/home/img/image1.jpg It works in visual studio localhost but it doesnt work online

There's a manner to work in both situation?

Thanks

您需要将Url.Content()辅助方法与根应用程序目录中的相对URL一起使用,因此无论基本目录名称是什么,它都可以在localhost和生产中使用:

@Url.Content("~/custom_directory/home/img/image1.jpg")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM