Advanced Setup of Web.config


The settings and functionality described in this section are configured in the Web.config file. Making changes to the Web.config file restarts Cartella and logs out all users.

Enabling and Viewing the Error Log

If a serious ASP.NET error occurs, it will be logged by the open source Error Logging Modules and Handlers (ELMAH) package. ELMAH generates a stack trace and maps the error to the class that caused it.

ELMAH maintains an internal log. At http://[SITE]/elmah.axd, you can view a graphical representation of the error log.

The ELMAH code is named in the <handlers> area of Web.config and should not be altered:

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

In the <elmah> element, you can set the security level of the log page using the value of the @allowRemoteAccess attribute.

ELMAH Element
<elmah>
    <security allowRemoteAccess="yes" />
    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>

Normally, @allowRemoteAccess should be set to no, so that the log is only accessible from the server on which the site is located.

More information on ELMAH settings can be found in Microsoft's online ASP.NET documentation: Logging Error Details with ELMAH (C#).

 

This section includes: