| | |
setting the web.config file
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2006
Posts: 45
Reputation:
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
Posts: 483
Reputation:
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
ASP.NET Syntax (Toggle Plain Text)
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); }
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
![]() |
Similar Threads
- 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
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn cac checkbox child class click commonfunctions compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownmenu dynamic edit embeddingactivexcontrol expose feedback findcontrol flash flv formatdecimal forms formview gridview homeedition iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings rotatepage save search security serializesmo.table silverlight smartcard sql sqlserver2005 ssl suse textbox tracking treeview typeof unauthorized validation vb.net video virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webdevelopment wizard xml youareanotmemberofthedebuggerusers





