为什么下面的行在 global.asax 中有错误:
string RelativeFilePath = "~/" + (AbsoluteFilePath.Replace(Request.ServerVariables["APPL_PHYSICAL_PATH"], String.Empty)).Replace("\\", "/");
错误 :
请求在此上下文中不可用
替代品是什么?
提前致谢
如果您在 IIS7 集成管道中托管应用程序,则 HttpContext 对象在Application_Start
。对于您的场景,您可以这样做:
string relativeFilePath = "~/" + AbsoluteFilePath
.Replace(HostingEnvironment.ApplicationPhysicalPath, String.Empty)
.Replace("\\", "/");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)