•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,454 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,764 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3138 | Replies: 6
![]() |
•
•
Join Date: Sep 2006
Posts: 45
Reputation:
Rep Power: 3
Solved Threads: 0
http://www.aspmessageboard.com/images/printer.gifhi all
I am trying to implement exception handling in my application, where I come accross some questions
I have set the customerror mode to renote only, and defaultredirect to a asp.net page.
1) do I have to comment that out, till i release the project?
2) for local host what will happen, if i set some page for the default error and error event?
For processing the unhandled exceptions, like sending mail to developer, what all I have to be careful
I am realy afraid of chanign something in web config
can anyone please clear my questions
thanks
I am trying to implement exception handling in my application, where I come accross some questions
I have set the customerror mode to renote only, and defaultredirect to a asp.net page.
1) do I have to comment that out, till i release the project?
2) for local host what will happen, if i set some page for the default error and error event?
For processing the unhandled exceptions, like sending mail to developer, what all I have to be careful
I am realy afraid of chanign something in web config
can anyone please clear my questions
thanks
•
•
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation:
Rep Power: 4
Solved Threads: 19
let me give you some sample code. You don't need to change web.config at all
you want to put this code in your global.asax code behind. This is for C#.Net but you should be able to convert it to VB.Net if thats what you are using
you want to put this code in your global.asax code behind. This is for C#.Net but you should be able to convert it to VB.Net if thats what you are using
protected void Application_Error(Object src, EventArgs e ){
string emAddr = "developer@yoursite.com"
string trc,message = "Application Error";
Exception objError = Server.GetLastError();
if(objError.InnerException != null)
objError = objError.InnerException;
HttpContext.Current.Application.Add("lastException",objError);
Server.ClearError();
trc = objError.StackTrace.Replace(" at ", "<li>");
trc = trc.Replace(" in ", "<br> ");
message = "<table>"+
"<tr><td colspan=2><b>Application Error</b></td></tr>"+
"<tr><td width=80 valign=top>Source:</td><td>"+ objError.Source + "</td></tr>"+
"<tr><td valign=top>Error:</td><td>"+ objError.Message +"</td></tr>"+
"</table><hr align=center width=80%><table>"+
"<tr><td>Stack Trace:</td></tr>"+
"<tr><td>"+ trc +"</td></tr></table>";
SendEmail(emAddr, "Application Error", message,true);
Server.Transfer("YourErrorPage.aspx");
}
public static void SendEmail(string To, string Subject, string Body, bool HTML) {
System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
mail.To = To;
mail.From = "whoever@yoursite.com";
mail.Subject = Subject;
mail.Body=Body;
mail.BodyFormat = (HTML?System.Web.Mail.MailFormat.Html:System.Web.Mail.MailFormat.Text);
System.Web.Mail.SmtpMail.SmtpServer = "yourmailserver";
System.Web.Mail.SmtpMail.Send(mail);
}•
•
Join Date: Jan 2007
Location: Japan
Posts: 70
Reputation:
Rep Power: 2
Solved Threads: 4
just add a global.asax file, right click the web project in solution explorer, click add
then select global.asax from the available files
then select global.asax from the available files
sedgey: so little daylight, too much caffeine
MCSD MCAD MCSE
http://www.thefriendlybuilder.co.uk,
http://www.sheetmusicdirect.com
MCSD MCAD MCSE
http://www.thefriendlybuilder.co.uk,
http://www.sheetmusicdirect.com
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
advertising ajax asp blog browser browsing community data design development devices dom domains feed firefox google html india intel internet legal linux marketing microsoft mobile applications mozilla multimedia news office php privacy reader report research search security software sql sun video w3c weather web web development wiki xml xoap yahoo youtube
- database string in web.config not working (ASP.NET)
- Web.config File (C#)
- Web Config file error (ASP.NET)
- role of web.config file in MVC (ASP.NET)
- smb/// no host "null" (*nix Software)
- wat is web.config (ASP)
Other Threads in the ASP.NET Forum
- Previous Thread: save a picture in SQL
- Next Thread: Radiobuttonlist setting attributes for radiobuttons


Linear Mode