473,396 Members | 2,023 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,396 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 1289
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.