2016-10-13 5 views
0

私は単純な.netウェブアプリケーションを持ち、IHttpに基づいてクラスを実装しています。このサンプルをMicrosoftのドキュメントから直接コピーしました。このクラスは、app_codeディレクトリにあります。App_codeのhttpModuleがローカルでデバッグするときにロードされない

HttpException(0x80004005が):型「httpModuleEx.App_Code.HelloWorldClass」をロードできませんでしたがここで

がある私のweb.configエントリ

問題は、私は、アプリケーションを実行するたびに、私は次のエラーを取得するということです

ここでHelloWorldClassを参照すると多くのバリエーションを試しましたが、どれも私のために働いていませんでした。

また、(app_codeディレクトリの下にある)HelloWorldClass.csファイルのビルドアクションを "コンパイル"しようとしました。以下は

HelloWorldClass.csファイルからコードされています

using System; 
using System.Web; 

namespace httpModuleEx.App_Code 
{ 
    public class HelloWordClass : IHttpModule 
    { 

     // In the Init function, register for HttpApplication 
     // events by adding your handlers. 
     public void Init(HttpApplication application) 
     { 
      application.BeginRequest += (new EventHandler(this.Application_BeginRequest)); 
      application.EndRequest += (new EventHandler(this.Application_EndRequest)); 
     } 

     private void Application_BeginRequest(Object source, EventArgs args) 
     { 
      HttpApplication application = (HttpApplication)source; 
      HttpContext context = application.Context; 
      string filePath = context.Request.FilePath; 
      string fileExtension = 
       VirtualPathUtility.GetExtension(filePath); 
      if (fileExtension.Equals(".aspx")) 
      { 
       context.Response.Write("<h1><font color=red>" + 
        "HelloWorldModule: Beginning of Request" + 
        "</font></h1><hr>"); 
      } 
     } 

     private void Application_EndRequest(Object source, EventArgs args) 
     { 
      HttpApplication application = (HttpApplication)source; 
      HttpContext context = application.Context; 
      string filePath = context.Request.FilePath; 
      string fileExtension = 
       VirtualPathUtility.GetExtension(filePath); 
      if (fileExtension.Equals(".aspx")) 
      { 
       context.Response.Write("<hr><h1><font color=red>" + 
        "HelloWorldModule: End of Request</font></h1>"); 
      } 

     } 

     public void Dispose() 
     { 

     } 
    } 
} 

任意の助けいただければ幸いです。

答えて

1

コードでWorldをWordとして表記している可能性があります:

+0

ありがとうございます! web.configのソリューションの一部については、他の記事を参照してください。 – user3019466

0

はい。ありがとうございました!また、web.configを次のように変更しました:

<system.webServer> 
    <validation validateIntegratedModeConfiguration="false"/> 
    <modules> 
     <remove name="ApplicationInsightsWebTracking"/> 
     <remove name="HelloWorldClass"/> 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" 
     preCondition="managedHandler"/> 
     <add name="HelloWorldClass" type="httpModuleEx.App_Code.HelloWorldClass, httpModuleEx"/> 
    </modules> 
    </system.webServer> 
関連する問題