在这种情况下,请求不可用-& gt;在Global.asax中-& gt;什么是替换 [英] Request is not available in this context -> In Global.asax -> what is replace
本文介绍了在这种情况下,请求不可用-& gt;在Global.asax中-& gt;什么是替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么以下行在global.asax中有错误:
why the below line has error in global.asax :
string RelativeFilePath = "~/" + (AbsoluteFilePath.Replace(Request.ServerVariables["APPL_PHYSICAL_PATH"], String.Empty)).Replace("\\", "/");
错误:
请求在这种情况下不可用
Request is not available in this context
什么是替代品?
预先感谢
推荐答案
如果将应用程序托管在IIS7集成管道中,则 Application_Start
中将不提供HttpContext对象.对于您的情况,您可以改为:
If you are hosting your application in IIS7 integrated pipeline HttpContext objects are not available in Application_Start
. For your scenario you could do this instead:
string relativeFilePath = "~/" + AbsoluteFilePath
.Replace(HostingEnvironment.ApplicationPhysicalPath, String.Empty)
.Replace("\\", "/");
这篇关于在这种情况下,请求不可用-& gt;在Global.asax中-& gt;什么是替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文