IIS7 集成模式中不存在 HttpContext.Current
我刚刚从经典模式切换到集成模式,现在 HttpContext 似乎不存在于我的 ASP.NET 应用程序中。我什至无法将 Watch 添加到 HttpContext 或 HttpContext.Current。
我正在使用 FluorineFX,其中在 Web.config 中定义了 HttpModule。显然,在IIS7集成模式下,这些HttpModule需要添加到System.WebServer中的Modules部分。我已经这样做了,但现在我遇到了 HttpContext 问题...
知道为什么会发生这种情况吗?
代码位于由 Flex (amf) 调用的简单服务类中。
if (HttpContext.Current.User.Identity != null)
{
...
Web.Config(我不知道如何在堆栈中正确显示它......):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<sectionGroup name="fluorinefx">
<section name="settings" type="FluorineFx.Configuration.XmlConfigurator, FluorineFx" requirePermission="false"/>
</sectionGroup>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<cachingConfiguration configSource="WebCachingConfiguration.config"/>
<dataConfiguration defaultDatabase="ConnectionString"/>
<spring>
<context>
<resource uri="~/spring/Commands.xml"/>
<resource uri="~/spring/Management.xml"/>
<resource uri="~/spring/DomainModel.xml"/>
<resource uri="~/spring/Repositories.xml"/>
<resource uri="~/spring/Services.xml"/>
<resource uri="~/spring/MsmqQueues.xml"/>
<resource uri="~/spring/MsmqMessageQueueTemplates.xml"/>
<resource uri="~/spring/Jobs.xml"/>
</context>
</spring>
<log4net configSource="WebLog4Net.config"/>
<connectionStrings configSource="WebConnectionString.config"/>
<appSettings configSource="WebAppSettings.config"/>
<fluorinefx>
<settings configSource="WebFluorineFX.settings.config"/>
</fluorinefx>
<system.web>
<globalization culture="nl-BE"/>
<customErrors mode="RemoteOnly"/>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
</compilation>
<authorization>
<allow users="*"/>
</authorization>
<!-- ignored when anonymous authentication is enabled in IIS -->
<authentication mode="Windows"/>
<identity impersonate="false"/>
<httpRuntime maxRequestLength="100000" executionTimeout="1800"/>
<caching>
<outputCache enableOutputCache="true"/>
<outputCacheSettings>
<outputCacheProfiles>
<add duration="500000" enabled="true" varyByParam="hashCode;thumb" name="AssetCacheProfile" noStore="false"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<sessionState timeout="20"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<system.webServer>
<modules>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<!-- Edumatic 3 Custom HttpHandlers -->
<add name="UploadUsers.aspx_*" path="UploadUsers.aspx" verb="*"
type="Edu3.Core.HttpHandler.UploadUsersHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0" />
<add name="UploadItems.aspx_*" path="UploadItems.aspx" verb="*"
type="Edu3.Core.HttpHandler.UploadItemsHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0" />
<add name="UploadBinaryAssetFile.aspx_*" path="UploadBinaryAssetFile.aspx" verb="*"
type="Edu3.Core.HttpHandler.UploadBinaryAssetFileHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0" />
<add name="ExportSession.aspx_*" path="ExportSession.aspx" verb="*"
type="Edu3.Core.HttpHandler.ExportSessionHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0" />
<add name="ExportSessions.aspx_*" path="ExportSessions.aspx" verb="*"
type="Edu3.Core.HttpHandler.ExportSessionsHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0" />
<add name="ValidateSessions.aspx_*" path="ValidateSessions.aspx" verb="*"
type="Edu3.Core.HttpHandler.ValidateSessionsHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0"/>
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers>
<caching>
<profiles>
<add extension=".swf" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".flv" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".gif" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".png" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".mp3" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".jpeg" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".jpg" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
</profiles>
</caching>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>
<!-- ************************************************************************* -->
<!-- Runtime Section -->
<!-- Telerik needs this runtime declaration and maybe some of our custom pages -->
<!-- ************************************************************************* -->
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I just switched from Classic Mode to Integrated Mode and now HttpContext doesn't seem to exist in my ASP.NET application. I can't even add a Watch to HttpContext nor to HttpContext.Current.
I'm using FluorineFX where in the Web.config a HttpModule is defined. Apparently, in IIS7 Integrated Mode, these HttpModules need to be added to the Modules section in System.WebServer. I have done this, but now I'm having this HttpContext problem...
Any idea as why this could happen?
Code is in a simple service class being called by Flex (amf).
if (HttpContext.Current.User.Identity != null)
{
...
Web.Config (I don't know how to display this properly in Stack...):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<sectionGroup name="fluorinefx">
<section name="settings" type="FluorineFx.Configuration.XmlConfigurator, FluorineFx" requirePermission="false"/>
</sectionGroup>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<cachingConfiguration configSource="WebCachingConfiguration.config"/>
<dataConfiguration defaultDatabase="ConnectionString"/>
<spring>
<context>
<resource uri="~/spring/Commands.xml"/>
<resource uri="~/spring/Management.xml"/>
<resource uri="~/spring/DomainModel.xml"/>
<resource uri="~/spring/Repositories.xml"/>
<resource uri="~/spring/Services.xml"/>
<resource uri="~/spring/MsmqQueues.xml"/>
<resource uri="~/spring/MsmqMessageQueueTemplates.xml"/>
<resource uri="~/spring/Jobs.xml"/>
</context>
</spring>
<log4net configSource="WebLog4Net.config"/>
<connectionStrings configSource="WebConnectionString.config"/>
<appSettings configSource="WebAppSettings.config"/>
<fluorinefx>
<settings configSource="WebFluorineFX.settings.config"/>
</fluorinefx>
<system.web>
<globalization culture="nl-BE"/>
<customErrors mode="RemoteOnly"/>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
</compilation>
<authorization>
<allow users="*"/>
</authorization>
<!-- ignored when anonymous authentication is enabled in IIS -->
<authentication mode="Windows"/>
<identity impersonate="false"/>
<httpRuntime maxRequestLength="100000" executionTimeout="1800"/>
<caching>
<outputCache enableOutputCache="true"/>
<outputCacheSettings>
<outputCacheProfiles>
<add duration="500000" enabled="true" varyByParam="hashCode;thumb" name="AssetCacheProfile" noStore="false"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<sessionState timeout="20"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<system.webServer>
<modules>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<!-- Edumatic 3 Custom HttpHandlers -->
<add name="UploadUsers.aspx_*" path="UploadUsers.aspx" verb="*"
type="Edu3.Core.HttpHandler.UploadUsersHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0" />
<add name="UploadItems.aspx_*" path="UploadItems.aspx" verb="*"
type="Edu3.Core.HttpHandler.UploadItemsHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0" />
<add name="UploadBinaryAssetFile.aspx_*" path="UploadBinaryAssetFile.aspx" verb="*"
type="Edu3.Core.HttpHandler.UploadBinaryAssetFileHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0" />
<add name="ExportSession.aspx_*" path="ExportSession.aspx" verb="*"
type="Edu3.Core.HttpHandler.ExportSessionHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0" />
<add name="ExportSessions.aspx_*" path="ExportSessions.aspx" verb="*"
type="Edu3.Core.HttpHandler.ExportSessionsHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0" />
<add name="ValidateSessions.aspx_*" path="ValidateSessions.aspx" verb="*"
type="Edu3.Core.HttpHandler.ValidateSessionsHttpHandler, Edu3.Core"
preCondition="integratedMode,runtimeVersionv2.0"/>
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers>
<caching>
<profiles>
<add extension=".swf" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".flv" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".gif" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".png" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".mp3" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".jpeg" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
<add extension=".jpg" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="08:00:00" />
</profiles>
</caching>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>
<!-- ************************************************************************* -->
<!-- Runtime Section -->
<!-- Telerik needs this runtime declaration and maybe some of our custom pages -->
<!-- ************************************************************************* -->
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您尝试从 Application_Start 访问它,则会发生架构更改来阻止这种情况: IIS 7 Application_Start 更改。
AFAIK 它应该仍然存在于其他地方。
If you are trying to access it from Application_Start there has been a architectural change that prevents this: IIS 7 Application_Start changes.
AFAIK it should exist everywhere else still.