2014-01-17 59 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

相关问题