Configuration :: Error Handling - Crendentials To Send Email When Server Error Occurs?
Nov 14, 2010
When a server error occurs for whatever reasons (YSOD), the server will send a message via SMTP class. In my case, my company employs microsoft exchange and uses NTLM authentication for all domain users. I am authenticating users via NTLA windows integrated authentication. My question is, is it possible to utilize this authentication data, and pass it to the system.web SMTP username/password authentication scheme to send an email to me (the web developer) when the error occurs? I am pretty sure my company requires a username/pwd to send emails via SMPT on the ms exchange server.
I need to design a bug alert system, where the web support team is notified via email when a user of our website encounters an error of any sort (database exception, or a 404)What would be the best way to design this section of the project?
I have upgraded my laptop to Windows7, VS2010, .net Framework 4 and then upgraded my ASP.NET Web Application to ASP.NET 4.I am now getting the error: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?). This error occurs in a local web service thatI have written and was working before I upgraded my system.I think this has something to do with the changes made to the web.config file when my web application was upgraded to the .net 4 Framework.I have searched the forums and Goggle, but cannot solve my issue.
I use Custom errors in my web.config. It works for urls like www.x.com/x.aspx , but when I write something like :
www.x.com/name (I have Application_BeginRequest dealing with it on global.asax) on the live server, IIS bypasses my application and shows its own error page.
How can I disable IIS error handling and redirect where I want to?
I'm having a wicked time trying to redirect the different error scenarios to a custom error page. Basically, I have put some code in Application_Error in global.asax, and done the necessary web.config settings to use Custom Errors.
In global.asax on Application_Error, I stored the Server.GetLastError in Session. The reason I have to store it in Session is because (as far as I know) you lose the exception when using "ResponseRedirect". And the reason I have to use ResponseRedirect is because I am using an UpdatePanel with AJAX calls, and any exception during the AJAX call shows up as a JavaScript error, and doesn't get handled using the custom error page (see this post).
void Application_Error(object sender, EventArgs e){ ////must perform this check to avoid the "Session state is not available in this context" errors if (HttpContext.Current.Session != null) { Session["LastException"] = Server.GetLastError(); } else { // (I think this happens when there are compile-time errors) Server.Transfer("~/Oops.aspx"); }}void Session_Start(object sender, EventArgs e){ //must perform this check to avoid the "Session state is not available in this context" errors if (HttpContext.Current.Session != null) { //initialize the session (http://forums.asp.net/t/1405077.aspx) Session["LastException"] = ""; }}
I have introduced site wide exception handling on my site to catch unexpected errors. The event handler sends a message to me when such an exception occurs. But the problem is that any clicks on my site will cause an exception to be thrown with the message: "This is an invalid webresource request."
I googled for an answer and only found a couple of references to 1. setting a fixed machinekey (which for some reason didn't work for me, I got an error saying that the virtual directory wasn't set in IIS, and as far as I know I'm not using IIS at all, I'm using the local development environment and then deploy to a web host) or 2. using a robots.txt file to stop robots from accessing the axd files, but that doesn't help either because it's not robots that cause the problem, anyone clicking around on the page will cause this error. how to solve this problem properly? For now I have handled it by catching and ignoring this particular error by the text in the error message, which works but I would rather fix it so that this error doesn't occur at all.
This code is working fine in my local system but when i upload it on server then it gives this error. From the last 1 year it was working fine but from last few days it gives me above said error, please suggest me is there any authentication required to send mail from server (my hosting plan is with 1and1.com)
I am trying to send a simple email through the following code:
protected void email_Click(object sender, EventArgs e) { System.Net.Mail.MailMessage msgMail = new System.Net.Mail.MailMessage(); msgMail.From = new System.Net.Mail.MailAddress("veerab@orbees.com"); msgMail.To.Add(new System.Net.Mail.MailAddress("murthyp@orbees.com")); msgMail.Subject = "Request:Joing into the myitem.Title.ToString()"; msgMail.IsBodyHtml = true; string strBody = "test mail"; msgMail.Body = strBody; System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); }
I have installed the SMTP server on my local machine. The folders in mail root have all the permissions. My mails stay in the Queue folder for sometime and then they go to the Badmail folder. I am receiving the following error: Unable to deliver this message because the follow error was encountered: "This message is a delivery status notification that cannot be delivered.". The specific error code was 0xC00402C7. The message sender was <>. The message was intended for the following recipients.
First I found that you can catch it and log it inside a catch, but this doesn't send an email. Then I found out about using the Error Signal class. That worked, however what wasn't apparent from reading, is that it treats the error like normal, so when I signal the error it goes to the custom error page still, I don't want that to happen. What I want to do is catch that error, log it, send the email, but stay on the page the error happened so I can provide special feedback. I do not want it go to the custom error page.
EDIT: This is what I have and it redirects me to the custom error page.
Try smtpClient.Send(mailMessage) Catch smtpEx As SmtpException errorSignal.FromCurrentContext().Raise(smtpEx) Catch ex As Exception errorSignal.FromCurrentContext().Raise(ex) End Try
Edit: Posting my web.config sections that involve Elmah (besides the connection string hah) And there is nothing in my Global.asax file involving Elmah.
Protected Sub Submitbutton_Click(sender As Object, e As System.EventArgs) Handles Submitbutton.Click Dim EMail1 As New MailMessage EMail1.From = New MailAddress("Receiver") EMail1.[To].Add(New MailAddress("Sender")) EMail1.Subject = Firstnametextbox.Text + lastnametextbox.Text + "Register " EMail1.Body = " This is content "
is there a way to configure the server / something else to send me an email every time asp.net crashes (with the error - just like the "yellow" screen it shows)
I have read several articles to send emails in Asp.net C# major are by using Gmail, I want to send email from a email id from mydomain name.The code that I am using is:
The code works properly would like to know whether the code is correct as I have have tested it by sending mails to gmail and rediffmail, it works properly, would also like to know the reason for using client.Port = 25;
MailMessage Msg = new MailMessage(); Msg.From = new MailAddress("sales@mydomain.com", "Testing"); Msg.To.Add(TxtEmail.Text); Msg.Subject = "Send Mail with HTML File"; Msg.Body = "Checking";
I have been tasked with implementing a strategy to catch all errors in an ASP.net application which cause a user request or interaction to crash and then e-mailk this exception to a support team in advance of a user calling about the error.Some errors however are not causing the page to crash or be redirected to the custom error page but these are being emailed to the support team instead of simply being loggedMy requirement is to seperate what exception types will cause a page fail and which will not.Example I am currently receiving a System.Web.HttpUnHandledException which is not causing any page to fall over and therefore is not of relevance to the support team. this can be logged but does not require emailing.
my problem that i have 2 website on godaddy and i need to creat a web form for feedback just fill some fileds and send it by email message.
i tray several ways in code but no one work if there is any one have a website on godaddy and have a web form to send e-mail explain to me or put your code
I am REALLY stuck with this and need a solution in the next 24 hours .i I have uploaded my asp.net web application to the web and have the database and connection strings functioning and reading the data from the database. But when I try to write to the DB
I get the following error :
Server Error in '/' Application.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
The wierd thing about this is the connection strings work from the local machine when I run from Visual Studio and I can write to the DB there, I just cannot write to the DB from the URL.
I am pretty new to asp.net but I am sure it has to be something to do with the web.config.
, I've researched this quite a bit and I'm just not seeing the problem. The app runs beautifully when living on my pc - the app on my pc connects successfully to the SQL Server 2008 Express Database (which sits on a server - not my pc). However, as soon as I publish this application to the server that the SQL Server 2008 Express Database sits on, I get this error when I try to run the application:
ERROR [42S02][Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid object name 'user'
It's behaving as if it either doesn't know where the table is when the app tries to run on the same server as the database or maybe the app doesn't have permission to hit the database once the app is on the same server as the database. I have connections on my pc and the server defined for this database, I verified that I set up each connection the same. I've also tried connecting using [dbo].[user] and this doesn't remedy the situation either. my connection string is in my web.config and it looks like this:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Default Role Provider could not be found.
I have OS windows 7(64 bits), Visual studio 2008 and Oracle 11g I have run "InstallAllOracleASPNETProviders.sql" who comes with the Oracle installation. When I run in debug I can run this application, but not otherwise. And in IIS manager, I can't se the Oracle provider? Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
I just got a new computer with Windows 7 and installed IIS, including support for ASP. I am running everything locally on my computer. A simple statement like <% response.write time() %> works fine, so ASP is working, However, when I try to run a page that accesses a database (at least, I am assuming that that is the root of the problem) then I get the unhelpful error message:An error occurred on the server when processing the URL. Please contact the system administrator.If you are the system administrator please click here to find out more about this error. I have no idea where to begin. the database is in the same location as it was on with my old computer, and I have adjusted permissions to the database so that everyone except Creator Owner has full permissions - for whatever reason I am not able to change Creator Owner permissions.
I have create user wizard control on my page as below with mail definition setup to send a welcome email to new registerd user.
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" requiresQuestionAndAnswer= "false" oncreateduser="CreateUserWizard1_CreatedUser" LoginCreatedUser="False"> <MailDefinition BodyFileName="~/EmailTemplates/CreateUserWizard.txt" From="myemailaddress" Subject="New User"> </MailDefinition> <WizardSteps> <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server" > <ContentTemplate> layout content here </ ContentTemplate> </WizardSteps > </asp:CreateUserWizard > Problem is I am not receiving the welcome email. To test it, I placed another create user wizard on another page in its default form as below <asp:CreateUserWizard ID="CreateUserWizard1" runat="server"> <MailDefinition BodyFileName="~/EmailTemplates/CreateUserWizard.txt" From="myemailaddress" Subject="New User"> </MailDefinition> <WizardSteps> <asp:CreateUserWizardStep runat="server" /> <asp:CompleteWizardStep runat="server" /> </WizardSteps> </asp:CreateUserWizard>
This one worked and I got welcome email. The setup in Web Config is correct. Is it because I have the oncreateduser="CreateUserWizard1_CreatedUser" or some other conflict issue.
I am currently trying to setup our website on a windows 2008 R2 64bit machine without much success. When I try to run the website I get the error detailed below. This only happens when I run the site under .NET 4. It works when I run it under .NET 2.
I have also tried going to a test aspx page to see what happens and it also give me the same error so it is obviously something to do with .NET 4 or the way I have it set up. I am thinking it might be a permissions thing but I am not sure what permissions should be set where. Please note this is the full version of .NET 4. The error I keep getting is:
HTTP Error 500.0 - Internal Server Error
An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.Detailed Error Information
Most likely causes: The module could not be found.IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
IIS was not able to process configuration for the Web site or application. The authenticated user does not have permission to use this DLL.
The code in the test.aspx is <%@ Page language="vb" %> <html> <body> [code]....