title: Are HttpModules utilized when a .Net web service is called through the javascript proxy (AJAX)?
body: <p>I am making our large set of web services available to AJAX calls. I have added the <code>[System.Web.Script.Services.ScriptService]</code> to each service. We have a registered HttpModule that initializes some objects we use regularly for logging and internationalization in the IHttpModule.Init override. It appears that the IHttpModule.Init is called when I make a SOAP request to any web method, but not when I make a JSON request to any web method. I've confirmed this by writing to a file when it's called.</p>
  
  <p>Are HttpModules utilized when a .Net web service is called through the javascript proxy (AJAX)? If so, am I lacking some sort of configuration? Relevant code bits included below.</p>
  
  <p>-colin-</p>
  
  <hr>
  
  <p>Web.config:</p>
  
  <pre><code>&lt;httpModules&gt;&lt;add name="GlobalApplicationModule" type="Common.GlobalApplicationModule, Common"/&gt;&lt;/httpModules&gt;
  </code></pre>
  
  <hr>
  
  <p>HTTPModules.cs:</p>
  
  <pre><code>class GlobalApplicationModule : IHttpModule
  {
    public void Dispose()
    {
        Internationalization.LanguageProvider.ReleaseAllResources();
    }
  
    public void Init(HttpApplication application)
    {
      // DEBUG: Confirm that this method is called
      StreamWriter writer = new StreamWriter("c:\\deleteme-HTTP_module_test.txt");
      writer.WriteLine("Init called.");
      writer.Close();
  
      // Initialize logger
      Common.Logger.Initialize("LogAssemblyPath", "LogClassName");
  
      Common.CentralConfiguration.CreateConfiguration(new  Common.CentralizedStrategy());
  
      // Initialize language provider
      if (!Internationalization.LanguageProvider.Initialized)
      {
        try 
        {
          string debug = System.Configuration.ConfigurationManager.AppSettings["debugInternationalization"];
          string languageAssemblyLocation = System.Configuration.ConfigurationManager.AppSettings["LanguageAssemblyLocation"];
          string languageAssemblyBaseName = System.Configuration.ConfigurationManager.AppSettings["LanguageAssemblyBaseName"];
          languageAssemblyLocation = System.Web.HttpContext.Current.Server.MapPath(languageAssemblyLocation);
          Internationalization.LanguageProvider.Init(languageAssemblyLocation, languageAssemblyBaseName, false);
          if (debug != null &amp;&amp; bool.Parse(debug))
          {
            Internationalization.LanguageProvider.PrefixText = "*";
          }
        }
        catch (Exception x)
        {
          Common.Logger.Instance.LogError("Could not intialize assembly language provider.  Error: " + x.Message);
        }
      }
    }
  }
  </code></pre>