I have the same web app working in three others servers. Anyone have any idea why is not working in the 4th server? See the error and stacktrace:
So if you place a breakpoint on the line:
UserPrincipal userAD = UserPrincipal.FindByIdentity(context, user.Login);
and step through it, it generates the above exception which does not have any InnerExceptions?
According to the stack trace, that line is the beginning of the problem. The returned exception should have at least some other information in it as to why it was thrown.
The following method takes the top level exception and returns a tab and linebreak formatted breakdown of the inner exceptions as a string.
private static string InnerExceptionConcatenator(Exception ex, int tabTracker = 0)
{
string retVal = "";
if (ex.InnerException != null)
{
tabTracker ++;
retVal = string.Format( "{0}\r\n{1}{2}", ex.Message, new String('\t', tabTracker), InnerExceptionConcatenator(ex.InnerException));
}
else
{
retVal = ex.Message;
}
return retVal;
}
You can call it thusly:
try
{
}
catch(ex Exception)
{
var exceptionString = InnerExceptionConcatenator(ex);
var path = @"c:\temp\exception.txt";
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(exceptionString);
}
}
else
{
using (StreamWriter sw = File.AppendText(path))
{
sw.WriteLine(exceptionString);
}
}
}