Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 810799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:56:32+00:00 2026-05-15T00:56:32+00:00

need to implement a global error handling, so maybe you can help out with

  • 0

need to implement a global error handling, so maybe you can help out with the following example…

i have this code:

public bool IsUserAuthorizedToSignIn(string userEMailAddress, string userPassword)
        {
            // get MD5 hash for use in the LINQ query
            string passwordSaltedHash = this.PasswordSaltedHash(userEMailAddress, userPassword);

            // check for email / password / validity
            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;

                // true if user found
                return (users.Count() == 1) ? true : false;
            }
        }

and the md5 as well:

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 would i go about handling exceptions from these functions? they first one is called from the Default.aspx page. the second one is only called from other functions from the class library.

what is the best practice?

  • surround code INSIDE each function with try-catch
  • surround the FUNCTION CALL with try-catch
  • something else??

what to do if exceptions happen?

in this example:
this is a user sign in, so somehow even if everything fails, the user should get some meaningful info – along the lines: sign in ok (just redirect), sign in not ok (wrong user name / password), sign in not possible due to internal problems, sorry (exception happened).

for the first function i am worried if there is a problem with database access.
not sure if there is anything that needs to be handled in the second one.

thnx for the info. how would you do it?
need specific info on this (easier for me to understand), but also general info on how to handle other tasks/functions.

i looked around the internet but everyone has different things to say, so unsure what to do… will go with either most votes here, or most logicaly explained answer 🙂 thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:56:33+00:00Added an answer on May 15, 2026 at 12:56 am

    Your library code or the code that is
    used by higher-layers in your
    application must always only throw
    exceptions and never worry about how
    to deal with them.

    This is important because you may use this library at many places for different purposes.

    In your application presentation layer, if you’re consuming a library code and you’re aware about the possible exceptions then do catch them with try/catch.

    Since you’re using asp.net I’d recommend to write a common page-base class and work some error handling mechanism in Page_Error event that catches all un-handled exceptions on the page.

    Even beyond that you can use Application_Error even in global.asax to catch any un-handled exception in any part of the application, Modules, Handler, services, pages etc.

    I’d strongly recommend to not make it
    a general practice to handle all
    exception in global Application_Error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a WCF service and I need to implement error handling. In ASP.NET
I have implemented global error handling in my global.asax file to handle any exceptions
I need to implement following using code: <basicHttpBinding> <binding name=NewBinding> <security mode=TransportCredentialOnly> <transport clientCredentialType=Basic
I want to Scheduling in Asp.net I have following options to implement this To
I need to implement portable code, but I do not know how to deal
I need to implement the following: There is a table A which is supposed
I've recently discovered a way to implement RESTful services using Global.asax (by handling the
I need to implement compiler (lexical, syntax and semantic analyzers). I have already implemented
I'm working with Spring-Security and I need to implement my own PermissionEvaluator (following the
I have inherited some code that is in need of a bit of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.