我正在使我们的大量web服务可用于AJAX调用。我已经将[System.Web.Script.Services.ScriptService]添加到每个服务中。我们有一个注册的HttpModule,它初始化了在IHttpModule.Init覆盖中用于日志记录和国际化的一些对象。当我向任何web方法发出SOAP请求时,IHttpModule.Init似乎都会被调用,而不是当我向任何web方法发出JSON请求时。我已经确认了这一点,当文件被调用时,我会将其写入文件。
当通过javascript (AJAX)调用HttpModules web服务时,是否使用了.Net?如果是的话,我是不是缺少某种配置?相关代码位包括在下面。
科林-
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);
}
}
}
}发布于 2010-03-16 21:35:39
这是一个非常奇怪的调试日志记录方法..。您的问题很可能是由于您的IIS配置。听起来IIS根本没有将请求传递给ASP.NET。检查你的映射。
https://stackoverflow.com/questions/2456598
复制相似问题