Catching an error friendly in a page

Posted by Jopito under ASP.NET on 1/22/2014 | Points: 10 | Views : 1348 | 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


Responses

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

Up
0
Down
Hi Refer this link

http://www.dotnetfunda.com/forums/show/8227/server-error-in-3939-application-runtime-error

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