2011-07-21 42 views
1

1-我有一個類結構,如下所示。HttpModules配置錯誤

namespace ViewStateSeoHelper 
{ 
class ViewStateSeoModule : IHttpModule 
{ 
    public void Init(HttpApplication context) 
    { 
     context.BeginRequest += new EventHandler(context_BeginRequest); 
    } 
    void context_BeginRequest(object sender, EventArgs e) 
    { 
     HttpApplication application = sender as HttpApplication; 
     if (application.Context.Request.Url.AbsolutePath.Contains(".aspx")) 
      application.Response.Filter = new HtmlFilterStream(application.Response.Filter); 
    } 
    public void Dispose() 
    { 
    } 
    } 
} 

我使用類似的東西在所有這些頁面中使用上面的代碼。

<httpModules> 
    <add name="ViewStateSeoModule" type="ViewStateSeoModule" /> 
</httpModules> 

但是,我得到了配置錯誤。

Parser Error: Could not load type 'ViewStateSeoModule'. (C:\Users\xxx\Documents\Visual Studio 2010\WebSites\xxx\web.config line 78) Line 78:

在此先感謝。

回答

1

你在一個命名空間包裹你的代碼,但在web.config中沒有提到它:

<httpModules> 
    <add name="ViewStateSeoModule" type="ViewStateSeoHelper.ViewStateSeoModule" /> 
</httpModules> 
0

type屬性需要包含您的名稱空間。嘗試:

<httpModules> 
    <add name="ViewStateSeoModule" type="ViewStateSeoHelper.ViewStateSeoModule" /> 
</httpModules>