you need to implement global error handling, so maybe you can help in the following example ...
I have this code:
public bool IsUserAuthorizedToSignIn(string userEMailAddress, string userPassword)
{
string passwordSaltedHash = this.PasswordSaltedHash(userEMailAddress, userPassword);
using (UserManagementDataContext context = new UserManagementDataContext())
{
var users = from u in context.Users
where u.UserEMailAdresses.Any(e => e.EMailAddress == userEMailAddress)
&& u.UserPasswords.Any(p => p.PasswordSaltedHash == passwordSaltedHash)
&& u.IsActive == true
select u;
return (users.Count() == 1) ? true : false;
}
}
and md5:
private string PasswordSaltedHash(string userEMailAddress, string userPassword)
{
MD5 hasher = MD5.Create();
byte[] data = hasher.ComputeHash(Encoding.Default.GetBytes(userPassword + userEMailAddress));
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
stringBuilder.Append(data[i].ToString("x2"));
}
Trace.WriteLine(String.Empty);
Trace.WriteLine("hash: " + stringBuilder.ToString());
return stringBuilder.ToString();
}
so how could I handle exceptions to these functions? they are first called from the Default.aspx page. the second - only from other functions from the class library.
What is the best practice?
- volumetric code INSERT each function with
try-catch - surrounds a FUNCTION CALL with
try-catch - something other
What to do if exceptions occur?
:
, , , - - : ok ( ), ( /), - , ( ).
, .
, -, .
thnx . ?
( ), , /.
, , , , ... , :) .