0

I have a .NET 4 WebAPI app that's using the ASP.NET SqlMembershipProvider.

When it works, it works fine - but if there's any problems connecting to the membership database, I just get a silent failure and the browser shows an HTTP 500 server error.

I'm using log4net to log application warnings and errors, but I cannot work out how - or where - to catch exceptions raised by the SqlMembershipProvider so they can be logged. Using Application_Error or explicitly attaching a handler to the application's Error event doesn't seem to work. Any ideas?

Dylan Beattie
  • 53,688
  • 35
  • 128
  • 197

2 Answers2

0

Nothing in the Event logger? Also, is log4net configured correctly? I've had a lot of problems with it in the past, which has generally made me use NLog as at least with that I can get it to complain lots when things go wrong...

Tom Parker-Shemilt
  • 1,679
  • 15
  • 26
0

Have you tried creating custom error filter and registering it in global.asax?

Your 500 seems like internal server error that wasn't handled.

To avoid copy-pasting my code or code from tutorial, visit this link and it should give you enough answer. You can trigger your logging within action filter:

http://www.asp.net/web-api/overview/web-api-routing-and-actions/exception-handling

Admir Tuzović
  • 10,997
  • 7
  • 35
  • 71