Catching an error friendly in a page

Posted by Jopito under ASP.NET on 1/22/2014 | Points: 10 | Views : 633 | Status : [Member] | Replies : 1
Hellow.i have a class Called Students where i have several methods.In my method for creating students,i first check if that student exists then i throw error back to him if found.What it brings back to me is the Exception since i have used a throw statement and it brings that annoying YELLOW SCREEN OF DEATH .I need someone to tell me how i can use a response.redirect so as instead of throwing that error,it redirects him to a custom error page i have created,

Here is the code on the Students Class

Student exist = db.Students.FirstOrDefault(x => x.studentName == studentName);
if (exist != null)

throw new Exception("Student Exists");

Mark as answer if satisfied


Posted by: muralikrishnasurap-12704 on: 1/22/2014 [Member] Starter | Points: 25

Hi Refer this link

Help you to understand how to create custom error page and how to redirect to custom error page when application throws exception

Best Regards
Murali Krishna.S

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response