473,796 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CustomErrors Trapping in a Page

SMG
Hi All,

I am using following code in web.confiig for trapping all the error through
out my site..

<customErrors mode="On" defaultRedirect ="WebForm1.aspx ">
<error statusCode="404 " redirect="Serve rError.aspx"></error>
<error statusCode="500 " redirect="WebFo rm3.aspx"></error>
</customErrors>

It works very fine... but On the final page e.g WebForm3.aspx I want catch
the error and want to show it on the screen.
so i wrote following code in webform3.aspx

string strErrorMsg = "Applicatio n Error\n\n";

// Get the path of the page
strErrorMsg += "Error in Path :" + Request.Path;

// Get the QueryString along with the Virtual Path
strErrorMsg += "\n\n Error Raw Url :" + Request.RawUrl;

// Create an Exception object from the Last error
//that occurred on the server
Exception myError =Server.GetLast Error();

// Get the error message
strErrorMsg += "\n\nError Message :" + myError.Message ;

Regards,
Shailesh Gajare
Nov 19 '05 #1
1 1078
Hi SMG:

What happens? Do you see an error message?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 8 Apr 2005 12:37:11 +0530, "SMG" <SM*@nodmain.co m> wrote:
Hi All,

I am using following code in web.confiig for trapping all the error through
out my site..

<customError s mode="On" defaultRedirect ="WebForm1.aspx ">
<error statusCode="404 " redirect="Serve rError.aspx"></error>
<error statusCode="500 " redirect="WebFo rm3.aspx"></error>
</customErrors>

It works very fine... but On the final page e.g WebForm3.aspx I want catch
the error and want to show it on the screen.
so i wrote following code in webform3.aspx

string strErrorMsg = "Applicatio n Error\n\n";

// Get the path of the page
strErrorMsg += "Error in Path :" + Request.Path;

// Get the QueryString along with the Virtual Path
strErrorMsg += "\n\n Error Raw Url :" + Request.RawUrl;

// Create an Exception object from the Last error
//that occurred on the server
Exception myError =Server.GetLast Error();

// Get the error message
strErrorMsg += "\n\nError Message :" + myError.Message ;

Regards,
Shailesh Gajare


Nov 19 '05 #2

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

Similar topics

6
6129
by: John Smith | last post by:
I am trying to implement custom error pages and I get this error message: **************************************************************************** ******** **************************************************************************** ******** Server Error in '/mfg' Application. ---------------------------------------------------------------------------- ----
21
4984
by: nicholas | last post by:
Although in my web.config I have <customErrors mode="off" /> I still get no detailed errors. How comes ? THX This is what I get: Server Error in '/mywebfolder'Application.
6
1484
by: SMG | last post by:
Hi , Sory for incomplete message in last post here is the actual problem.. I am using following code in web.confiig for trapping all the error through out my site.. <customErrors mode="On" defaultRedirect="WebForm1.aspx"> <error statusCode="404" redirect="ServerError.aspx"></error> <error statusCode="500" redirect="WebForm3.aspx"></error>
9
4274
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it programatically possible in VB.NET to read the contents of web.config's <customErrorselement? I looked at using ConfigurationSettings.AppSettings, but that doesn't work. I need to read the value of redirect from the error statusCode 404. My web.config looks like this: <customErrors mode="RemoteOnly" defaultRedirect="Error.aspx"> <error statusCode="404" redirect="Error404.aspx" /> </customErrors>
0
9531
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10018
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.