Closed carlosagsmendes closed 10 years ago
I'm unable to repro this, can you post your web.config sections please? My best guess is an incorrect string in there when referencing the handler.
Hi Nick:
Please find a copy of the web.config below.
You can also download a copy of my sample project (empty web application) here
I get the error when I hit the exceptions.axd url.
Thanks
<configSections>
<section name="Exceptional" type="StackExchange.Exceptional.Settings, StackExchange.Exceptional"/>
</configSections>
<Exceptional applicationName="Core">
<IgnoreErrors>
<!-- Error messages to ignore (optional) -->
<Regexes>
<add name="connection suuuuuuuucks" pattern="Request timed out\.$" />
</Regexes>
<!-- Error types to ignore, e.g. <add type="System.Exception" /> or -->
<Types>
<add type="MyNameSpace.MyException" />
</Types>
</IgnoreErrors>
<!-- Error log store to use -->
<ErrorStore type="Memory" />
<!--<ErrorStore type="JSON" path="~\Errors" size="200" rollupSeconds="300" />-->
<!--<ErrorStore type="SQL" connectionString="Data Source=.;Initial Catalog=Exceptions;Uid=Exceptions;Pwd=iloveerrors" />-->
</Exceptional>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<handlers>
<!-- OPTIONAL: if not using a router, or you don't want to access the errors directly via this application,
this is not necessary. A common scneario for this is logging all errors to a common SQL store and viewing
them through another application or a dashboard elsewhere.
Note: If the error list isn't exposed in the application, any errors in logging exceptions will be queued up,
but not visible (since that's exposed on the error list view).
-->
<add name="Exceptional" path="exceptions.axd" verb="POST,GET,HEAD" type="StackExchange.Exceptional.ExceptionalModule, StackExchange.Exceptional" preCondition="integratedMode" />
</handlers>
<!-- Here the error log needs to be registered to catch all unhandled exceptions,
these are exceptions that make it all the way to being a 500 page the user sees. -->
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="StackExchange.Exceptional.ExceptionalModule, StackExchange.Exceptional" />
</modules>
</system.webServer>
</configuration>
What version of IIS are you using?
IIS Express in VS2013
I ran into this error too while using the sample web.config. The problem is when requesting exceptions.axd. The fix is to change the type from ExceptionalModule to HandlerFactory as per below, in the system.webServer/handlers part of web.config
<add name="Exceptional" path="exceptions.axd" verb="POST,GET,HEAD" type="StackExchange.Exceptional.HandlerFactory" resourceType="Unspecified" preCondition="integratedMode" />
Many thanks!
Hi, It's nice to implement Exceptional to my project. But can you tell me how can i log my handled exceptions in StackExchange's Exceptional? and is there any way to log activities?
@tmAsim Please don't comment on old tickets for something that's completely unrelated to the ticket. If you need help, create a new ticket.
The way you log handled exceptions is by sending the exception to ErrorStore.LogException
. It's really simple and is included in the wiki.
As for logging other events that aren't related to exceptions, there really isn't a simple way to do that since everything is based on logging exceptions. However, you could create a new class that inherits System.Exception
and throw, catch, and log that into Exceptional. Here's an example.
public static class Logging
{
private class InfoOnlyException : System.Exception { }
public static void LogMessage(string message)
{
try
{
throw new InfoOnlyException(message);
}
catch (Exception ex)
{
StackExchange.Exceptional.ErrorStore.LogException(ex, HttpContext.Current);
}
}
}
You would then call Logging.LogMessage
from your code when you want to add a message into your ErrorStore
.
I was trying the sample MVC app and the Exceptions.axd handler is not working:
Server Error in '/' Application.
StackExchange.Exceptional.ExceptionalModule, StackExchange.Exceptional does not implement IHttpHandlerFactory or IHttpHandler.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Configuration.ConfigurationErrorsException: StackExchange.Exceptional.ExceptionalModule, StackExchange.Exceptional does not implement IHttpHandlerFactory or IHttpHandler.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ConfigurationErrorsException: StackExchange.Exceptional.ExceptionalModule, StackExchange.Exceptional does not implement IHttpHandlerFactory or IHttpHandler.] System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type) +9657807 System.Web.Configuration.HandlerFactoryCache..ctor(String type) +19 System.Web.HttpApplication.GetFactory(String type) +86 System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +262 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18045