IIS 7.0集成模式中Application_Start不能使用HttpContext.Current
2009-09-21 22:57 Tam 阅读(1106) 评论(0) 编辑 收藏 举报在IIS7集成模式中,当我们在Global.asax的Application_Start中使用HttpContext.Current.Request.ApplicationPath获得当前虚拟目录路径,会得到以下的错误:
Server Error in '/IIS' Application.
Request is not available in this context
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Web.HttpException: Request is not available in this context
Source Error:
Line 6: { Line 7: // Code that runs on application startup Line 8: var appPath = HttpContext.Current.Request.ApplicationPath; Line 9: } Line 10: |