2

私の MVC4 アプリケーションでは、NUGET を使用して ELMAH をアプリケーションにロードしました。しかし、web.config では、次のエラー メッセージが表示されます。

場所要素は使用されていません。elmah.axd にプロジェクト アイテムが見つかりません。

この名前でファイルを作成するつもりですか? これを修正するにはどうすればよいですか?

<location path="elmah.axd" inheritInChildApplications="false">
    <system.web>
      <httpHandlers>
        <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
      </httpHandlers>


        See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for 
        more information on using ASP.NET authorization securing ELMAH.

      <authorization>
        <allow roles="admin" />
        <deny users="*" />  
      </authorization>


    </system.web>
    <system.webServer>
      <handlers>
        <add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
      </handlers>
    </system.webServer>
  </location>
4

3 に答える 3

4

Elmah.MVC.dll を使用する場合、elmah.axd のハンドラーを追加する必要はありません。Elmah.MVC.dll には、 http://www.yourwebsite.com/elmahのログにアクセスできるコントローラーが含まれています。これについては、次の場所で完全に説明されています。

https://github.com/alexanderbeletsky/elmah.mvc

elmah.axd ハンドラーよりも構成が簡単なため、この方法をお勧めします。

于 2013-03-13T23:33:07.447 に答える
0

RegisterRoutes に以下を追加する必要があります。

routes.IgnoreRoute("elmah.axd/{*pathInfo}");

于 2013-03-13T12:56:22.057 に答える
0

I installed Elmah.MVC through NuGet.

Most of the web.config settings were automatically added by the install.

Had to add:

<httpHandlers>
      <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>

and:

<handlers>
      <add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</handlers>

then at the very bottom of the config there will be an empty section so I modified it to:

<elmah>
    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>

and logging to an XML file worked!

Note, you may have to tweak logPath if it isn't appropriate.

Gina! VS2012, MVC4, all updates/sp applied

于 2013-03-27T20:01:35.020 に答える