为什么Server.MapPath在路径中添加额外的目录

时间:2019-02-05 14:27:28

标签: c# asp.net asp.net-web-api rdlc server.mappath

我正在使用HttpContext.Current.Server.MapPath函数来查找StudentReport.rdlc下的Class Library Project文件。

解决方案结构:

enter image description here

我正在从名为Class Library Project的{​​{1}}调用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目录。

当前路径:

WebDemo

预期路径:

"C:\\Users\\tom\\source\\repos\\WebDemo\\WebDemo\\StudentLib\\Reports\\StudentReport.rdlc"

我可以知道为什么会这样吗?

任何帮助都会很棒。

0 个答案:

没有答案
相关问题