KenyaPlex.com
    Colleges   Schools   Universities   Alumni Directory   Courses   Interview Questions   Forum   Question Papers   Members   Online Tests   Tutorials  
Sign In    RegisterBusiness DirectoryJobs Submit Resume Ask a QuestionChat Room Upload Photo Advertise Here Web Design Who is new?


Alumni Directory
Join our alumni directory today and find your current or former classmates from school, college or university.
Join Now!

Search for schools
Get information on all schools in Kenya. Choose from the best.

Colleges
Find all colleges in Kenya from our easy to use colleges directory.

Universities
Find both public and private universities.

Discussion Forum
Discuss and share ideas. Ask questions and get answers

Interview Questions
Browse our collection of interview questions and resources and prepare yourself to win interviews.

Kasneb CPA Syllabus

Registered Members
phillip omondi onyango
James mwabaya jumah
mutiso
Evelyn Psenjen
felix mwema mwendwa

More Members | Register

 
Skip Navigation LinksHome > >Discussion Forum > >Automatically sending email alert when an error occurs on a website
 

Automatically sending email alert when an error occurs on a website


Last Updated: 06/23/2010 02:14:54
Total Responses: 1
Posted By: samuel
Errors do occur on websites and websites. Sometimes, you may need to know where the error occured and the nature of the error. In asp.net, this is made easy using Application_Error in Global.asax file.
The error sent will have details of the error source and nature.
The code below shows how to implement an email error reporting system in asp.net websites and web applications.

protected void Application_Error(Object sender, EventArgs e) {
Exception objError = Server.GetLastError().GetBaseException();
string strError = "Error Has Been Caught in Page_Error event<hr>
" + "
Error in: " + Request.Url.ToString() + "
Error Message: " + objError.Message.ToString() + "
Stack Trace:
" + objError.StackTrace.ToString(); MailMessage Mail = new MailMessage();
Mail.To="youremail@yourdomain.com";
Mail.From ="youremail@yourdomain.com";
Mail.Subject = "Application Error";
Mail.Body = strError.ToString();
Mail.Priority = MailPriority.Normal;
Mail.IsBodyHtml = true;
SmtpClient client = "yoursmtpclient";
client.Send(Mail);
}

Please replace the "youremail@yourdomain.com" and "yoursmtpclient" with the email address and smtp server which you are using.

Responses

raphael says..
This is very crucial as it can be used as a reporting tool whenever something goes wrong on your asp.net website. If you have some knowledge in asp.net, you can change the message to suit your requirements.

05 Aug 2009 @ 04:18

Post Reply/Response


You must Sign In  to post a response.

More Resources


Diploma in Entrepreneurship Development Module II Examination Subjects
Change your diploma or work experience to a degree
KASNEB PastPapers
Government Sponsorship
KASNEB Registration Dates
Kabianga University College Re-Opening Dates
Ram Hospital School of Nursing Intake
Moi University School of Law
Moi University School of Natural Resource Management
African Advanced Level Telecommunications Institute (AFRALTI) Upcoming Courses
 



About Us | Contact Us | Privacy Policy | Advertise

Copyright © 2008 KenyaPlex.com: A website for Education in Kenya, Resources, Jobs and Interview Questions - All rights reserved.