【问题标题】:Server Error loading HttpModule服务器加载 HttpModule 时出错
【发布时间】:2012-06-19 01:16:34
【问题描述】:

我很困惑,需要一些建议来解决以下错误 我正在进入配置为使用的应用程序 我创建的一个 HttpModule:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not load type 'namespaceResponseModifier.ResponseModifer'. 

...

Exception Details: System.Web.HttpException: Could not load
type 'namespaceResponseModifier.ResponseModifer'.

...

Stack Trace: 

[HttpException (0x80004005): Could not load type 'namespaceResponseModifier.ResponseModifer'.]

...

[ConfigurationErrorsException: Could not load type 'namespaceResponseModifier.ResponseModifer'.]

...

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 

网络服务器是 IIS Express 7.0。

在 web.config 文件中,元素的代码是:

   <system.webServer>
       <modules>
           <add name="ResponseModifier"
                type="namespaceResponseModifier.ResponseModifer" />
       </modules>
   </system.webServer>

The assembly for the HttpModule resides in 
C:\...\HttpModulePreSendRequestContentCS\Bin\ResponseModifier.dll

我也尝试将 HttpModule 的源代码放在 App_Code 目录中 但我在加载 HttpModule 时仍然收到服务器错误。

在第二种情况下,我收到以下错误:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not load type 'namespaceResponseModifier.ResponseModifer' from assembly 'App_Code'. 

...

Exception Details: System.TypeLoadException: Could not load
type 'namespaceResponseModifier.ResponseModifer' from assembly 'App_Code'.

...

Stack Trace: 

[TypeLoadException: Could not load type 'namespaceResponseModifier.ResponseModifer' from
assembly 'App_Code'.]

...

[ConfigurationErrorsException: Could not load type 'namespaceResponseModifier.ResponseModifer'
from assembly 'App_Code'.]

...

[HttpException (0x80004005): Could not load type 'namespaceResponseModifier.ResponseModifer'
from assembly 'App_Code'.]

...

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

我也尝试过使用 Visual Studio Development Web Server 而不是 IIS Express Web Server。 我在这两种情况下都尝试了这个服务器: - 使用 bin 文件夹中的程序集 - 使用 App_Code 文件夹中的源代码。

这些场景分别产生以下错误:

Server Error in '/HttpModulePreSendRequestContentCS' Application.
--------------------------------------------------------------------------------

Configuration Error 

...

Parser Error Message: Could not load type 'ResponseModifer'.
(C:\...\HttpModulePreSendRequestContentCS\web.config line 8)

...

Source File: C:\...\HttpModulePreSendRequestContentCS\web.config    Line: 8 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272


Server Error in '/HttpModulePreSendRequestContentCS' Application.
--------------------------------------------------------------------------------

Configuration Error 

...

Parser Error Message: Could not load type 'ResponseModifer' from assembly 'App_Code'.  
(C:\...\HttpModulePreSendRequestContentCS\web.config line 8)

...

Source File: C:\...\HttpModulePreSendRequestContentCS\web.config    Line: 8 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

任何关于我可以做些什么来解决问题的建议将不胜感激。

【问题讨论】:

    标签: web-config httpmodule iis-express


    【解决方案1】:

    老问题,但我认为您的模块添加不正确。

    <add name="NameOfModule" type="Namespace.NameOfModule, AssemblyName" />
    

    这是我看到它的典型方式,所以不知道这个模块的命名空间,它看起来更接近:

    <add name="ResponseModifier" type="ActualNameSpaceGoesHere.namespaceResponseModifier.ResponseModifer, ResponseModifier" />
    

    【讨论】:

      猜你喜欢
      • 2015-01-30
      • 2010-10-09
      • 2014-11-12
      • 2017-05-24
      • 2012-05-25
      • 2012-08-12
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      相关资源
      最近更新 更多