views:

115

answers:

1

I am making our large set of web services available to AJAX calls. I have added the [System.Web.Script.Services.ScriptService] 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.

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.

-colin-


Web.config:

<httpModules><add name="GlobalApplicationModule" type="Common.GlobalApplicationModule, Common"/></httpModules>

HTTPModules.cs:

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 && bool.Parse(debug))
        {
          Internationalization.LanguageProvider.PrefixText = "*";
        }
      }
      catch (Exception x)
      {
        Common.Logger.Instance.LogError("Could not intialize assembly language provider.  Error: " + x.Message);
      }
    }
  }
}
A: 

That's a very odd debug logging method... Your problem is most likely due to your IIS configuration. It sounds like IIS is not handing off the request to ASP.NET at all. Check your mappings.

Bryan