たぶんこれは最善の方法ではありませんが、うまくいきます。
// Here is your path
String p = photosLocation + "whatever.jpg";
// Here is the page address
String pa = Page.Request.Url.AbsoluteUri;
// Take the page name
String pn = Page.Request.Url.LocalPath;
// Here is the server address
String sa = pa.Replace(pn, "");
// Take the physical location of the page
String pl = Page.Request.PhysicalPath;
// Replace the backslash with slash in your path
pl = pl.Replace("\\", "/");
p = p.Replace("\\", "/");
// Root path
String rp = pl.Replace(pn, "");
// Take out same path
String final = p.Replace(rp, "");
// So your picture's address is
String path = sa + final;
編集:わかりました、誰かが役に立たないとマークしました。いくつかの説明: 現在のページの物理パスを取得し、サーバーとディレクトリ (c:\inetpub\whatever.com\whatever など) とページ名 (/Whatever.aspx など) の 2 つの部分に分割します。画像の物理パスにはサーバーのパスが含まれている必要があるため、それらを「差し引き」、サーバーの相対的な画像のパスのみを残します (例: \design\picture.jpg)。バックスラッシュをスラッシュに置き換えて、サーバーの URL に追加します。