2014-01-17 58 views
0

可以說我有兩個應用程序爲:
www.test.com/a
www.test.com/b創建兩個asp.net應用程序之間的下載鏈接

站點B,我有一個頁面設置爲下載PDF文件。該頁面被稱爲OpenBook.aspx,當我在查詢字符串中傳遞bookId時,它會下載相關文件。

這裏下載從站點B文件,通過點擊鏈接的代碼:

lbl.Text =;「報告書{0}

完成並準備觀點。」

現在這個工地B內部,但它顯然是因爲路徑設置爲www.test.com/a/Processing/OpenReportBook.aspx不A.內工作.....

我嘗試使用以下:

string downloadLocation = HttpContext.Current.Request.Url.Host.ToString() + "/DataCenter/Processing/OpenReportBook.aspx?ReportID="; 
        Label2.Text = "Report book <a href='" + downloadLocation + 
                     + 948 + 
                     "'>{0}</a> is completed and ready for view. "; 

但儘管如此,路徑是相對於網站的一組,當您從網站A.點擊

可有人請解釋如何解決這個問題?

感謝

回答

2

不使用HttpContext.Current.Request.Url.Host.ToString()

而是給web.config中的第二網址如下

<appSettings> 
    <add key="downloadurl" value="http://www.test.com/b" /> 
</appsetings> 

而在你的cs文件替換如下因素代碼

string downloadLocation = HttpContext.Current.Request.Url.Host.ToString() + "/DataCenter/Processing/OpenReportBook.aspx?ReportID="; 
        Label2.Text = "Report book <a href='" + downloadLocation + 
                     + 948 + 
                     "'>{0}</a> is completed and ready for view. "; 

string downloadLocation = ConfigurationManager.AppSettings[downloadurl"].ToString() + "/DataCenter/Processing/OpenReportBook.aspx?ReportID="; 
        Label2.Text = "Report book <a href='" + downloadLocation + 
                     + 948 + 
                     "'>{0}</a> is completed and ready for view. "; 

我希望這可能會解決你的問題。

+0

感謝Pawan,它的工作! – devC

相關問題