473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Exception handling in web applications

Hi,

How to handle exceptions and show messages in a web application? In windows application we can create a log file and show the message on message box.What is the way to do it in a web application?

Thanks in advance.
Nov 22 '05 #1
4 1284
Be very careful here! I was just at a TechNet discussion and the subject
was Web Security and one of the biggest points they made was not exposing
exceptions to users. Hackers will often try to break the app and gain info
from the exception message. One fairly large company got one of their
primary tables truncated and the attacker was able to do it by injection
attacks coupled with info from the exception message which told him what to
hit.

You have a few choices as far as developer exceptions go. First off, I'd
recommend against using MessageBoxes, use assertions and in the try catch
block use Debug.Assert(false, ex.ToString()); it'll give you a little more
flexibility. Either way it's not going to happen with the web. You could
serialize your exceptions and write them to an XML file for one thing. Many
times we use debug constants and set a place on the web server to write
exceptions when it's in debug mode. Then when we switch to release, it stops
and all is good. YOu can also write to event logs although you'll need some
increased permissions to do this and if your app throws a lot of exceptions,
they can fill up quickly (although it takes a fair volume to do this to the
point its a pain for most small to mid sized apps). Finally you can write
the exceptions to db, you can just serialize them and in your serialization
routine write to the db. The main problem with this approach is if DB
connectivity is what's throwing the excetion, then you may throw new ones
and you probably won't be able to write them out. Finally you can use SMTP
or Pop and mail the messages to yourself which is pretty decent for
production but a bit slow for development and testing.

Probably debug.Writeline and Assertions using Debug or Trace will work for
giving you timely info as a developer . For other stuff you can write to
the event logs or use one of the other approaches. HTH,

Bill
"Kshitij" <an*******@discussions.microsoft.com> wrote in message
news:27**********************************@microsof t.com...
Hi,

How to handle exceptions and show messages in a web application? In windows application we can create a log file and show the message on message
box.What is the way to do it in a web application?
Thanks in advance.

Nov 22 '05 #2
Be very careful here! I was just at a TechNet discussion and the subject
was Web Security and one of the biggest points they made was not exposing
exceptions to users. Hackers will often try to break the app and gain info
from the exception message. One fairly large company got one of their
primary tables truncated and the attacker was able to do it by injection
attacks coupled with info from the exception message which told him what to
hit.

You have a few choices as far as developer exceptions go. First off, I'd
recommend against using MessageBoxes, use assertions and in the try catch
block use Debug.Assert(false, ex.ToString()); it'll give you a little more
flexibility. Either way it's not going to happen with the web. You could
serialize your exceptions and write them to an XML file for one thing. Many
times we use debug constants and set a place on the web server to write
exceptions when it's in debug mode. Then when we switch to release, it stops
and all is good. YOu can also write to event logs although you'll need some
increased permissions to do this and if your app throws a lot of exceptions,
they can fill up quickly (although it takes a fair volume to do this to the
point its a pain for most small to mid sized apps). Finally you can write
the exceptions to db, you can just serialize them and in your serialization
routine write to the db. The main problem with this approach is if DB
connectivity is what's throwing the excetion, then you may throw new ones
and you probably won't be able to write them out. Finally you can use SMTP
or Pop and mail the messages to yourself which is pretty decent for
production but a bit slow for development and testing.

Probably debug.Writeline and Assertions using Debug or Trace will work for
giving you timely info as a developer . For other stuff you can write to
the event logs or use one of the other approaches. HTH,

Bill
"Kshitij" <an*******@discussions.microsoft.com> wrote in message
news:27**********************************@microsof t.com...
Hi,

How to handle exceptions and show messages in a web application? In windows application we can create a log file and show the message on message
box.What is the way to do it in a web application?
Thanks in advance.

Nov 22 '05 #3
Hi Kshitjij

Save them on your webserver in either the standard logging, a speciallogfile
or in your database.

And of course in a for standard users unreachable place.

Cor
Nov 22 '05 #4
Hi Kshitjij

Save them on your webserver in either the standard logging, a speciallogfile
or in your database.

And of course in a for standard users unreachable place.

Cor
Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Abelardo Vacca | last post by:
Hello, I am currently in the process of switching our application to a N-Tier model with .NET. One of the aspects we want ot get right from the start not to worry about it after is the...
11
by: Master of C++ | last post by:
Hi, I am writing a simulation package in C++, and so far I've written about 8000 lines of code and have about 30 classes. I haven't used C++ exceptions so far (for various reasons). The only two...
7
by: Ori | last post by:
Hi, I would like to create some mechanism to handle all the exceptions which will happen in my application. I have one form which is the base form while all the other forms inherit from it. ...
2
by: Steph | last post by:
I am working on a Windows Forms App. I have attached a standard UnhandledExceptionEventHandler to the current domain to catch unexpected errors. In my application, when I trigger an unhandled...
4
by: Anirudha Vengurlekar | last post by:
Hello Community, We can have nested TRY , CATCH , FINALLY blocks in the application. So in what situation (in a class or in a function) I would use this nested Try catch blocks? If someone...
6
by: Kevin Jackson | last post by:
Let's say we log exceptions to the windows application event log using the Exception Management Application Block. Is there a pattern that can be used so the exception is logged only once and not...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
1
by: Noor | last post by:
Hi all, I am trying to catch all types of exceptions from a app regardless of whether it is in debugger mode( VS development environment) or run the.exe file outside the IDE. My App...
16
by: NewToCPP | last post by:
I have seen at several places that C++ programmers writing for RealTime Embedded applications dont use Exception Handling. They dont like Throw/catch concept. WHY? Thanks.
9
by: =?Utf-8?B?UmFq?= | last post by:
How do I know which methods will throw exception when I am using FCL or other third party .Net library? I am developer of mostly native Windows applications and now .Net. After working few...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.