When setting up asp.net error handlers for things like 404 errors, it is more 'efficient' to do this in IIS, or handle it in the Global.asax Application_Error event? I know the latter will be called, and I want to log this information in a database, but should I then just return without any redirect and let IIS do the redirect, or would it be better to do a response.redirect inside application_error once we've logged it?
We have an ASP.NET page which uses an update panel for partial page postbacks. On the server side, the postback performs some database work and updates several UI elements. The database code is all contained in several transactions, so the state will still be consistent if an exception is thrown. We're working on some error handling code now, and my first thought was to log the exception thrown, reload the last consistent UI state, and show some sort of modal popup or other ui element with a brief error message for the user (this is an intranet page, so we're automatically notified of the bug, and the users know where to find us.
I have an Application_Error handler in my Global.asax file. However, I load many pages using an XHR request and would rather these "sub pages" return javascript or a real 500 code for my main app to process, rather than an error page.
Is it possible to handle errors on certain pages in a different way? Can a master page handle its own errors in a page extending it without bubbling it up to Global.asax?
This morning I found myself dealing with A SQL POOLING ERROR Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. I did fix this with resetting my pooling and setting a pooling max =100 Anyway now Im starting to rethink how I open connections, dealing with errors and proper closing of connections Would you say this code below is a good way of opening, closing connections (even when errors occurred)
Dim Connection As SqlConnection Dim myConn As String = (ConfigurationManager.ConnectionStrings("MyConnString").ConnectionString) Connection = New SqlConnection(myConn) Try Dim DBCommand As SqlCommand Dim dt As New DataTable() Dim myDataSet As New DataSet Connection.Open() DBCommand = New SqlCommand("GetAllCategories_", Connection) DBCommand.CommandType = CommandType.StoredProcedure DBCommand.Parameters.Add("@HomePageID", SqlDbType.Int).Value = HiddenChosenVirtualMainID.Value Dim mySqlAdapter As New SqlDataAdapter(DBCommand) mySqlAdapter.Fill(dt) SecondLevelChildDatalist.DataSource = dt SecondLevelChildDatalist.DataBind() Catch ex As Exception 'Error goes here SqlConnection.ClearAllPools() Finally 'close the connction Connection.Close() Connection.Dispose() End Try
I really want to switch over to ajax, but i can't seem to get my error handlling perfect. If i can't handle errors correctly, I just can't use it. What I really want to happen is to do a full refresh of the Top Frame. How I normally do this is by a similar call to Response.Write(<script>top.location.href = ""</script>). I was currently doing this in Global.asax. This becomes a problem when I error out in an AJAX postback. I've also noticed that There is an AsycPostbackErrorHandler you can attach to the ScriptManager. This is all find an dandy, but it will still hit my Global.asax Application_Error Event.
I am honestly just not sure how to handle this.
As I said, the result I want is....To Reload the Top Frame with some Error Message...whether I have to do some weird redirection or whatever. My problem lies specifically with the Global.asax file.
On my site I put things in Web user controls. For example, I will have a NewsItem Control, an Article Control, a ContactForm control.These will appear in various places on my site.
What I'm looking for is a way for these controls to pass messages up to the Page that they exist on.
I don't want to tightly couple them, so I think I will have to do this with Events/Delegates. I'm a little unclear as to how I would implement this, though.
A couple of examples:
1: A contact form is submitted. After it's submitted, instead of replacing itself with a "Your mail has been sent" which limits the placement of that message, I'd like to just notify the page that the control is on with a Status message and perhaps a suggested behaviour. So, a message would include the text to render as well as an enum like DisplayAs.Popup or DisplayAs.Success
2: An Article Control queries the database for an Article object. Database returns an Exception. Custom Exception is passed to the page along with the DisplayAs.Error enum. The page handles this error and displays it wherever the errors go.
I'm trying to accomplish something similar to the ValidationSummary Control, except that I want the page to be able to display the messages as the enum feels fit.
Again, I don't want to tightly bind or rely a control existing on the Page. I want the controls to raise these events, but the page can ignore them if it wants.I'd love a code sample just to get me started.
I know this is a more involved question, so I'll wait longer before voting/choosing the answers.
I'm working on a functionality in my asp.net web site that enables the user to download some files as a zip file. I'm using the DotNetZip library to generate the zip file.
Now, if anything goes wrong, say the Utils.ExportToZip method fails, I want to present an error message to the user and not the download dialog. Do I have to remove some data from the Response object in order to cancel the download operation?
I am learning on how to create data access layer code for a web site. I want to ensure I am actually connecting to the datasource, so, I am wanting to use a try/catch block within my data access layer class methods. What I am not sure how to handle is a case where the connectionstate is not open. The method should ideally return a datatable. If an error is thrown would I just return an empty datatable? That is my first thought. My other thought is to return an object and pass a datatable if the connection succeeds or the exception if the connection fails.
I am trying to sort out a problem where some relative urls are not resolving properly in an ASP.NET website. I want to see the HTTP logs to determine which URLs are being requested from the web server. I am using the ASP.NET Development Server, not IIS.So are there logs produced by the ASP.NET Development Server where I can check which files are being requested?Windows 7, 64bitVS2008 ASP.NET 3.5 SP1
I am trying to run a WCF Data Service using the ASP.Net Dev server (aka Cassini). When I hit F5 I get the following message in my browser:
Request Error The server encountered an error processing the request. See server logs for more details. However, I don't know where Cassini puts its server logs. Does anyone out there know?
I have a C# web forms ASP.NET 4.0 web application that uses Routing for URLs for some reason custom errors defined in the system.web section of my web.config is entirely ignored and it will fall back the IIS errors.
This gets entirely ignored
[code]....
This would be a minor inconvenience except that by the fact it falls back to IIS native instead of my application it completely circumvents Elmah logging my 404 exceptions correctly.
I'm trying to import csv file that that uses double qoutes from the text qualifer but doesn't use any qualifiers for the numbers or null fields. The data looks like this:
I keep getting "Bulk load data conversion error (type mismatch or invalid character for the specified codepage)" when it tries to insert null from the csv into a numeric data type.
I tried changing the codepage, datafiletype, fieldterminator, formatfile but I still can't get it to work.
I've been writing an app using the awesome new Razor view engine and for the most part, things have been great.
One issue I keep running into, however, is that if I should happen to write invalid code, such as referencing a null property or even a non existent property, rather than throwing an error, something happens in the background that causes the browser to wait and wait and wait and if I do not cancel the browser's request quick enough, IIS will simply hang.
It seems as if it enters some sort of loop. CPU usage goes up (though not terribly high) and restarting IIS via either GUI or iisreset command seems to take abnormally long (presumably while it waits for the process to safely shutdown).
This also happens for other invalid code scenarios such as failing to close a code block with a closing brace.
We have been receiving reports of the following server error periodically from users. [OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown.] [HttpException (0x80004005): Unable to serialize the session state.] Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is "StateServer" or "SQLServer".
Once in a state where this error appears, it appears to be hit or miss whether the errors are reproducible locally. If they are, then we can usually reproduce them for a couple minutes, but not on every page hit. This usually tapers off on its own and usually has resolved itself by the time we get back in contact with the users. The Web Service has around 90-100 active connections during business hours. The only other site on this server is the staging version of this site, which gets hit very infrequently. The Session State is stored on the same SQLServer instance as the application database which is housed on a fairly large cluster of virtual machines.
Neither the Web Server or the SQLServer seemed to be taxed (either processor or memory-wise) while this is going on. The distribution of which pages are erroring seems to be comparable to the normal distribution for each page. There doesn't appear to be any pattern in terms of times of occurrence. We do have less errors on average on weekends (which correlates to normal site load), but even this appears to not be consistent. There also doesn't appear to be a correlation between the errors logged and any kind of logged performance monitor events. This includes an array of perfmon counters including:
.NET CLR Jit(w3wp) otal # of IL Bytes Jitted .NET CLR Jit(w3wp)IL Bytes Jitted / sec .NET CLR Jit(w3wp)\% Time in Jit .NET CLR Jit(w3wp)# of Methods Jitted .NET CLR Jit(w3wp)# of IL Bytes Jitted ASP.NET Apps v1.1.4322(__Total__)Requests Failed ASP.NET Apps v1.1.4322(__Total__)Errors Unhandled During Execution/Sec ASP.NET Apps v1.1.4322(__Total__)Errors Unhandled During Execution ASP.NET Apps v1.1.4322(__Total__)Cache Total Turnover Rate ASP.NET Apps v1.1.4322(__Total__)Errors During Preprocessing ASP.NET Apps v1.1.4322(__Total__)Errors During Execution ASP.NET Apps v1.1.4322(__Total__)Requests Executing ASP.NET Apps v1.1.4322(__Total__)Requests Total ASP.NET Apps v1.1.4322(__Total__)Errors Total ASP.NET Apps v1.1.4322(__Total__)Sessions Abandoned ASP.NET Apps v1.1.4322(__Total__)Errors Total/Sec ASP.NET Apps v1.1.4322(__Total__)Anonymous Requests/Sec ASP.NET Apps v1.1.4322(__Total__)Requests/Sec ASP.NET Apps v1.1.4322(__Total__)Session SQL Server connections total ASP.NET Apps v1.1.4322(__Total__)Cache Total Hit Ratio ASP.NET v1.1.4322Requests Current ASP.NET v1.1.4322Request Execution Time MemoryPages/sec Bytes Total/sec PhysicalDisk(_Total)Avg. Disk Queue Length Processor(_Total)\% Processor Time Web Service CacheFile Cache Hits % Web Service CacheFile Cache Misses Web Service CacheFile Cache Hits Web Service(_Total)Current Connections Web Service(_Total)Post Requests/sec)
The only pattern I can see in the logs doesn't correlate to the occurrence of these errors, but is the only pattern I can see. Looking at the perfmon logs we are seeing a pattern where the "Total # of IL Bytes Jitted", "IL Bytes Jitted / sec", "% Time in Jit", "# of Methods Jitted", and "# of IL Bytes Jitted" counters for the staging site (which shouldn't be getting any traffic) doesn't pull data for a 20-50 minute period after which there is an immediate spike in "IL Bytes Jitted / sec" and a jump in "% Time in Jit" for 2-20 minute of up to 99% for the main site.
I'm new to ASP.NET and I am trying to create a website which requires a database.I created a localhost mdf database and I tried two ways of attaching the files but still received errors.(i) Connecting by Windows Authentication: filed with the operating system error 3 (The system cannot find the path specified (Error 5133)(ii) Connecting by SQL Authentication: CREATE FILE encountered operating system error 5 (Access is denied) while attempting to open or create the physical path file. (Error 5123)If you don't mind me bugging you for a while so that I can setup my database please add me on MSN timothyky@hotmail.com. I still have a couple questions in regards to the web.configuration afterwards.
When I build my program, if there's one error that prevents it from running, instead of just getting the one error I'll get around 50 additional errors in addition to the real one such as:
Error 27 Validation (XHTML 1.0 Transitional): This name contains uppercase characters, which is not allowed.
I am running an Update statement against an SQL database on server 2008. The update runs but does not update the record, but returns no errors.The database is part of a commercial help desk package called TrackIt 8.5 which was just a fresh install on a new web server and a new sql server. The update is running from a web form we use to automatically create active directory accounts. After the account is created the web form closes out the work order in the Trackit db. This was working fine when the system was running on Server 2003 and SQL server 2005. Running Trackit version 7.02.The login use to access the database has full permissions to read and write to the database, just as it did on the old server which never had an issue updating. Odd thing is, if I log onto the SQL server and make a change to any single field in that record. I can then run the web form and it updates the record normally.
I got these errors while trying to run a web application using vs 2008, The first error is this: >Application has generated an exception that could not be handled. >process ID=0x1130 (4400), Thread ID=0xe6c (3692). And when I press OK a second dialog reports this error:>unable to connect to the asp.net development server. I reinstalled, repaired and re registered msdbg2.dll and edited hosts file but still get this error. I need to debug an application but I can't. This error is on a 'Win 2003 server enrterprise service pack 1' with a vs2008 team system installation. What can I do to remove this error and run and debug my application?
I am using JQuery for all of my client side validation and Asp.net validator controls for all of my server side validation. I am using an errorlabelcontainer to store the client side validations in a summary at the top of the page, which is the requirement. All works well. My problem is, I want to display the server side asp.net errors in the same errorlabelcontainer OR display all of the client side errors in the validation summary. Either way, Both errors need to be in the same place/div. Any ideas on how to do this? I thought of maybe using the asp.net validation summary as the errorcontainer in JQuery, but I cannot find the summary. This is what I have right now.