Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Http模块-发送Http标头后,服务器无法修改Cookie_C#_Iis_Httphandler_Httpmodule - Fatal编程技术网

C# Http模块-发送Http标头后,服务器无法修改Cookie

C# Http模块-发送Http标头后,服务器无法修改Cookie,c#,iis,httphandler,httpmodule,C#,Iis,Httphandler,Httpmodule,我创建了一个新的缓存层。其角色是为缓存中的页面提供服务。如果该页不在缓存中,它将允许实际请求继续 我的httpmodule是这样的 <modules runAllManagedModulesForAllRequests="true"> <remove name="WebDAVModule" /> <add type="myCacheModule.Class, myCacheMoldule" name="NewlyAddedmyCacheM

我创建了一个新的缓存层。其角色是为缓存中的页面提供服务。如果该页不在缓存中,它将允许实际请求继续

我的httpmodule是这样的

  <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
      <add type="myCacheModule.Class, myCacheMoldule" name="NewlyAddedmyCacheMoldule" />
      <add type="OtherModules1" name="OtherModules1" />
      <add type="OtherModules2" name="OtherModules2" />
 </modules>
虽然代码执行得很好,但我得到了以下错误

异常:System.Web.HttpException消息:服务器无法修改 HTTP头发送后的cookies

我认为我的模块没有任何问题,但我认为由于我使用response.flush,其他被调用的模块会抛出这个错误

有没有一种方法可以说,如果第一个模块中的某些条件匹配,那么不执行其余的任何一个

我知道没有办法控制HTTPModules的执行,它们按照配置的顺序异步执行,我正在尝试看看是否有解决问题的方法

 private void ExecuteCacheLayer(HttpApplication context) {
      var httpContext = context.Context;
      var request = httpContext.Request;
      var response = httpContext.Response;
      if (CacheExists(request)) {
       var result = //method to get page from cache


       response.Write(result.ResponseBody);
       response.Flush();
       context.CompleteRequest();
      }