I’m developing a web project where i need to add custom exception classes. For example, how can i display a message from my custom exception class when the session timeout occurs? Please help. Any sample will be helpful.
This is what i written in my exception class so far:
public class CustomException : Exception
{
private string message;
public CustomException ()
{
this.message = "Invalid Query";
}
public CustomException (String message)
{
this.message = message;
}
}
Need to know how to link this with the session timeout, from where i need to write the logic of the same. Thank You.
If you are looking to throw your custom
exceptionwhen the is raised you can do it like this.Not too sure if this is what you are trying to do.
Update:
To Find out if SqlException is a TimeoutException please see this StackOverFlow Post.