How Can Make Custom Exception Class And His Use In Asp.Net

Step 1: Make a New Web Site and Add a new item choose class.cs file and rename to him Given Name CustomException Class As Given Below

Step 2: Now Write Down Given Below Code Into Your Class and Derived System.exception class

Here we are just Overriding to Exception class properties and methods

Step 3: go into ToolBox and Place a Button and on his double click write down Given Code

/// <summary>
/// Summary description for CustomException
/// </summary>
public class CustomException : System.ApplicationException
public CustomException()
// TODO: Add constructor logic here
public override string Message
return “An Error Occured In Your Application”;


On button Click Code

CustomException ex=new CustomException();

if (Server.MapPath(“Default2.aspx”).Equals(true))






Label1.Text = ex.Message;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s