我在用
HttpContext.Current.Server.MapPath
函数来定位
StudentReport.rdlc
文件在
Class Library Project
.
解决方案结构:
我正在调用下面的函数
从一个
Web API Project
命名为
WebDemo
.
public class Reports
{
public string GetReportPath()
{
string path1 = System.AppDomain.CurrentDomain.BaseDirectory;
var path2 = System.Web.HttpContext.Current.Server.MapPath("~/StudentReport.rdlc");
var path3 = System.Web.HttpContext.Current.Server.MapPath("~/BL/ClassLib/StudentLib
/Reports/StudentReport.rdlc");
var path4 = System.Web.HttpContext.Current.Server.MapPath("~/StudentLib/Reports
/StudentReport.rdlc");
string path5 = System.Web.Hosting.HostingEnvironment.MapPath("~/StudentLib/Reports
/StudentReport.rdlc");
return path5;
}
}
如你所见,我试过所有的组合
Server.MapPath
网络演示
当前路径:
"C:\\Users\\tom\\source\\repos\\WebDemo\\WebDemo\\StudentLib\\Reports\\StudentReport.rdlc"
预期路径:
"C:\\Users\\tom\\source\\repos\\WebDemo\\StudentLib\\Reports\\StudentReport.rdlc"
我能知道为什么会这样吗?