2017-06-07 65 views
0

我需要創建Web API來生成一些圖像並返回它們的路徑。在IIS虛擬目錄上保存生成的圖像?

我創建路徑使用保存:

var resultPath = "Images/" + obiektId.ToString() + ".png"; 
var fullPath = HttpContext.Current.Server.MapPath("/" + resultPath); 

,並返回resultPath

問題是,我保留我的網站的虛擬目錄是C:\\sites\siteAHttpContext.Current.Server.MapPath("/" + resultPath)返回C:\\inetpub\wwwroot\Images\123456.png。那麼我無法從10.0.0.106/siteA/Images/123456.png加載圖片。

如何將我的映像保存在我的基本虛擬目錄中,而不是將其保存在wwwroot目錄中?

+1

試試這個'無功FULLPATH = HttpContext.Current.Server.MapPath( 「〜/」 + resultPath);' –

+0

@PranavPatel它的工作原理。謝謝:) –

+0

高興地幫助你 –

回答

0
string resultPath = obiektId.ToString() + ".png"; 
string fullPath = System.Web.HttpContext.Current.Server.MapPath("~/Images"+ resultPath);