积极答复者
碰到B/S结构一个新问题,网站发布后,图片取不到;

问题
答案
-
或许你可以利用"~"符号来指定网站目录中的相对位置,以利部署时可以顺利找到图片所在位置。
Image1.ImageUrl = "~/Imge/Sunset.jpg";
以上說明若有錯誤請指教,謝謝。
http://www.dotblogs.com.tw/terrychuang/- 已标记为答案 BU XI - MSFTModerator 2012年5月3日 3:15
全部回复
-
须用Url路径
先确保Sunset.jpg在网站目录内
之后用http://xxxxxx/SctWeb/Imge/Sunset.jpg(类似这样的Url路径来取得图片)
- The blog of typewriter職人
- Convert C# to VB.NET
- /*If my concept is wrong ,please correct me.Thanks.*/
- 已编辑 Shadow .Net 2012年4月26日 17:20
-
或许你可以利用"~"符号来指定网站目录中的相对位置,以利部署时可以顺利找到图片所在位置。
Image1.ImageUrl = "~/Imge/Sunset.jpg";
以上說明若有錯誤請指教,謝謝。
http://www.dotblogs.com.tw/terrychuang/- 已标记为答案 BU XI - MSFTModerator 2012年5月3日 3:15
-
如果想在后台取的绝对路径的话可以用 Server.MapPath
关于它的用法如下
./当前目录
/网站主目录
../上层目录
~/网站虚拟目录
如果当前的网站目录为C:\Inetpub应用程序虚拟目录为c:\Inetpub\wwwroot浏览的页面路径为c:\Inetpub\wwwroot\news\show.aspx
在show.aspx页面中使用
Server.MapPath("./") 返回路径为:c:\Inetpub\wwwroot\news
Server.MapPath("/") 返回路径为:c:\Inetpub
Server.MapPath("../") 返回路径为:c:\Inetpub\wwwroot
Server.MapPath("~/") 返回路径为:c:\Inetpub\wwwroot