Task.IsFaulted
is not capturing exception. It seems that IsFault
is not working. It is sending to else block even the condition is false. Can you plea
Instead of using IsFaulted
, just use try
/catch
:
try
{
await _emailSender.SendEmailAsync(contentRootPath, email, subject, comment, userid, fullname);
return @"
<!DOCTYPE html>
<html>
<head>
<meta charset='utf - 8' />
<title>MCP Feedback Facility</title>
</head >
<body >
<br />
<br />
<br />
<p>Feedback submitted successfully.</p>
</body>
</html>
";
}
catch
{
return @"
<!DOCTYPE html>
<html>
<head>
<meta charset='utf - 8' />
<title>MCP Feedback Facility</title>
</head >
<body >
<br />
<br />
<br />
<p>Sorry, your feedback submission was not completed successfully</p>
</body>
</html>
";
}
Side note: return await Task.FromResult<string>(responseString); is just a less efficient and less maintainable version of return responseString;