Elmah on IIS 7

1,664 views
Skip to first unread message

Rick

unread,
May 30, 2008, 9:57:49 AM5/30/08
to ELMAH
Has anybody got this to work on IIS 7? I've been trying for about a
day now and can't get it to work. I'm getting an IIS 404 error. To get
around this I tried adding a http module definition for elmah in IIS,
this then resulted in a "resource not found" asp.net error. I've read
every message I can find on 404 and resource not found but can't
figure it out. Could someone look at my web.config and/or let me know
if anyone figured out how to run this on IIS7? Thanks!

<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>


<configSections>
<sectionGroup name="system.web.extensions"
type="System.Web.Configuration.SystemWebExtensionsSectionGroup,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting"
type="System.Web.Configuration.ScriptingSectionGroup,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler"
type="System.Web.Configuration.ScriptingScriptResourceHandlerSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices"
type="System.Web.Configuration.ScriptingWebServicesSectionGroup,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization"
type="System.Web.Configuration.ScriptingJsonSerializationSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="Everywhere" />
<section name="profileService"
type="System.Web.Configuration.ScriptingProfileServiceSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication" />
<section name="authenticationService"
type="System.Web.Configuration.ScriptingAuthenticationServiceSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication" />
<section name="roleService"
type="System.Web.Configuration.ScriptingRoleServiceSection,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false"
allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
<sectionGroup name="elmah">
<section name="security" requirePermission="false"
type="Elmah.SecuritySectionHandler, Elmah"/>
<section name="errorLog" requirePermission="false"
type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false"
type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false"
type="Elmah.ErrorFilterSectionHandler, Elmah"/>
</sectionGroup>
</configSections>
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="Elmah.Sql" />
<!--<errorMail from="err...@conintranet.com"
to="rick...@teqservices.com"
cc=""
subject="CON Intranet Error"
async="true"
smtpPort="25"
smtpServer="localhost"
userName=""
password="" />-->
</elmah>

<appSettings/>
<connectionStrings>
<add name="SQLConnection" connectionString="Data
Source=local;Initial Catalog=UCDCON;Trusted_Connection=true"
providerName="System.Data.SqlClient"/>
<add name="Elmah.Sql" connectionString="Data Source=.;Initial
Catalog=UCDCON;Trusted_Connection=True" />
</connectionStrings>
<system.web>
<sessionState mode="StateServer" cookieless="false"
timeout="180"></sessionState>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">

<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>

</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms name=".ASPXAUTHENT" loginUrl="~Login.aspx"
slidingExpiration="true" protection="All" requireSSL="false"
timeout="200" path="/">
</forms>
</authentication>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly"
defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->


<pages styleSheetTheme="Default"
maintainScrollPositionOnPostBack="false">
<controls>
<add tagPrefix="asp" namespace="System.Web.UI"
assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls"
assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>

<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd"
type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</httpModules>

<trace enabled="true" pageOutput="true" requestLimit="10"
traceMode="SortByTime" localOnly="true" />

</system.web>

<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
warningLevel="4"
type="Microsoft.CSharp.CSharpCodeProvider, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
warningLevel="4"
type="Microsoft.VisualBasic.VBCodeProvider, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>

<!--
The system.webServer section is required for running ASP.NET
AJAX under Internet
Information Services 7.0. It is not necessary for previous
version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule" />
<add name="ScriptModule" preCondition="managedHandler"
type="System.Web.Handlers.ScriptModule, System.Web.Extensions,
Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx"
preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*"
path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode"
verb="GET,HEAD" path="ScriptResource.axd"
type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" />
</handlers>
</system.webServer>

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions"
publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0"
newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design"
publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0"
newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>


</configuration>

James_2JS

unread,
May 31, 2008, 3:07:09 AM5/31/08
to ELMAH
Hi Rick,

Please see the post I've just made to a previous question along the
same lines:

http://groups.google.com/group/elmah/browse_thread/thread/c678f3120d37f8a6?hl=en

You need to merge the <system.webServer> entries mentioned in that
post in with what you've already got for AJAX.

Hope this helps,

James

Rick

unread,
Jun 2, 2008, 9:43:06 AM6/2/08
to ELMAH
James, thanks! I got it to work by removing my entries in the
system.web and putting them under the system.webServer section. I was
a little confused by your post into thinking I needed to remove the
validation line, this caused other problems, so I reverted it back and
everything works now. So just to clarify for anyone else, I only
removed my entries under system.web > httphandlers and httpModules,
then put these entries into the system.webServer > modules and
handlers section. Thanks a ton.

Rick

On May 31, 1:07 am, James_2JS <jamesdrisc...@btinternet.com> wrote:
> Hi Rick,
>
> Please see the post I've just made to a previous question along the
> same lines:
>
> http://groups.google.com/group/elmah/browse_thread/thread/c678f3120d3...

James_2JS

unread,
Jun 2, 2008, 10:01:46 AM6/2/08
to ELMAH
Hi Rick,

Glad you're sorted!!

> I was> a little confused by your post into thinking I needed to remove the
> validation line, this caused other problems, so I reverted it back and
> everything works now.

Sorry for any confusion!!

> So just to clarify for anyone else, I only
> removed my entries under system.web > httphandlers and httpModules,
> then put these entries into the system.webServer > modules and
> handlers section.  Thanks a ton.

Here are the options...

1) if you want your web.config to work in Visual Studio/Cassini,
IIS5x, IIS6 and IIS7 you need to merge the following into your
web.config:

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="Elmah.ErrorLog" type="Elmah.ErrorLogModule, Elmah"
preCondition="managedHandler" />
<!--<add name="Elmah.ErrorFilter"
type="Elmah.ErrorFilterModule" preCondition="managedHandler" />-->
<!--<add name="Elmah.ErrorMail" type="Elmah.ErrorMailModule"
preCondition="managedHandler" />-->
</modules>
<handlers>
<add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD"
type="Elmah.ErrorLogPageFactory, Elmah"
preCondition="integratedMode" /
</handlers>
</system.webServer>

2) if you only ever want to run in IIS7 (and will never run in Visual
Studio/Cassini, IIS5x, IIS6) then here's what you do:
a) remove all reference to elmah in the httpModules and httpHandlers
sections
b) merge this into web.config

<system.webServer>
<modules>
<add name="Elmah.ErrorLog" type="Elmah.ErrorLogModule, Elmah"
preCondition="managedHandler" />
<!--<add name="Elmah.ErrorFilter"
type="Elmah.ErrorFilterModule" preCondition="managedHandler" />-->
<!--<add name="Elmah.ErrorMail" type="Elmah.ErrorMailModule"
preCondition="managedHandler" />-->
</modules>
<handlers>
<add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD"
type="Elmah.ErrorLogPageFactory, Elmah"
preCondition="integratedMode" /
</handlers>
</system.webServer>



NB the big difference between the two is this line in
<system.webServer>

<validation validateIntegratedModeConfiguration="false" />

If it is present, it tells IIS7 to ignore any issues with modules and
handlers being declared in <system.web>

Hope this clarifies things further!

Cheers,

James
Reply all
Reply to author
Forward
0 new messages