How to catch a COMException properly from ASP.NET?

1

We are using AD to authenticate user for our website, and sometimes the Web server is not be able to connect to the DC server, and we got a COMException (0x8007203a): The server is not operational.

Even when I catch this exception in a similar code block below, the exception is still not caught completely, and it is propagated to the Application_Error method in the Global.asax page. It happends only with this COMException, other .NET exceptions are caught and logged properly.

try
{
   // This line of code will start AD search and raise a COMException.
   SearchResult results = objAdSearcher.FindOne();
}
catch (COMException com)
{
  _handler.HandleException(com, ExceptionHandlingProvider.UnhandledPolicy);
  error = "The server is unable to process your login request. Please contact an        administrator.";
  return true;
}
asp.net
com
exception-handling
asked on Stack Overflow Feb 7, 2012 by Tien Do

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0