473,805 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't customErrors do in Global.asax

ad
I have set customErrors to On and set a defaultRedirect in Web.config like:

<customErrors mode="On"
defaultRedirect ="~/ErrorPage/GenericErrorPag e.aspx">

When I throw a exception in Global.asax like:
throw new Exception("This a Error Test !!");

It will not redirect to GenericErrorPag e.aspx, but if I throw the same
Exception in other web pages, it do.

What is problem? Can't customErrors do in Global.asax?
Mar 5 '06 #1
6 2367
Ad,
Global.asax isn't a "web page", and it doesn't normally have access to the
Request context process under which normal ASP.NET exception handling occurs.
What exactly is it that you want to do?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ad" wrote:
I have set customErrors to On and set a defaultRedirect in Web.config like:

<customErrors mode="On"
defaultRedirect ="~/ErrorPage/GenericErrorPag e.aspx">

When I throw a exception in Global.asax like:
throw new Exception("This a Error Test !!");

It will not redirect to GenericErrorPag e.aspx, but if I throw the same
Exception in other web pages, it do.

What is problem? Can't customErrors do in Global.asax?

Mar 5 '06 #2
ad
Peter,
Thanks,
I want to set some application variables in Application_Sta rt, if some error
occur, I wnat to redirect to some error page!
ad

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > ¼¶¼g©ó¶l¥ó·s»D: B8************* *************** ******@microsof t.com...
Ad,
Global.asax isn't a "web page", and it doesn't normally have access to the
Request context process under which normal ASP.NET exception handling
occurs.
What exactly is it that you want to do?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ad" wrote:
I have set customErrors to On and set a defaultRedirect in Web.config
like:

<customErrors mode="On"
defaultRedirect ="~/ErrorPage/GenericErrorPag e.aspx">

When I throw a exception in Global.asax like:
throw new Exception("This a Error Test !!");

It will not redirect to GenericErrorPag e.aspx, but if I throw the same
Exception in other web pages, it do.

What is problem? Can't customErrors do in Global.asax?

Mar 5 '06 #3
Hello ad,

Hmm. strange. Could you show your code? Because <customErrors mode="On" defaultRedirect ="Examples.aspx "/>
in Web.config and

protected void Application_Sta rt(Object sender, EventArgs e)
{
throw new Exception("my excep");
}

redirect me to the Examples.aspx page
a> Peter,
a> Thanks,
a> I want to set some application variables in Application_Sta rt, if
a> some error
a> occur, I wnat to redirect to some error page!
a> ad
a>
a> "Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com >
a> ¼¶¼g©ó¶l¥ó·s»D: B8************* *************** ******@microsof t.com...
a>
Ad,
Global.asax isn't a "web page", and it doesn't normally have access
to the
Request context process under which normal ASP.NET exception handling
occurs.
What exactly is it that you want to do?
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"ad" wrote:
I have set customErrors to On and set a defaultRedirect in
Web.config like:

<customErrors mode="On"
defaultRedirect ="~/ErrorPage/GenericErrorPag e.aspx">
When I throw a exception in Global.asax like:
throw new Exception("This a Error Test !!");
It will not redirect to GenericErrorPag e.aspx, but if I throw the
same Exception in other web pages, it do.

What is problem? Can't customErrors do in Global.asax?

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Mar 5 '06 #4
ad
Peters,
Thanks again.
Maybe there are some condition in my program which affect the redirection
action.
I will check again.

ad
"Michael Nemtsev" <ne*****@msn.co m>
???????:9c***** *************** ******@msnews.m icrosoft.com...
Hello ad,

Hmm. strange. Could you show your code? Because <customErrors mode="On"
defaultRedirect ="Examples.aspx "/> in Web.config and
protected void Application_Sta rt(Object sender, EventArgs e)
{
throw new Exception("my excep");
}

redirect me to the Examples.aspx page
a> Peter,
a> Thanks,
a> I want to set some application variables in Application_Sta rt, if
a> some error
a> occur, I wnat to redirect to some error page!
a> ad
a> a> "Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com >
a> ¼¶¼g©ó¶l¥ó·s»D: B8************* *************** ******@microsof t.com...
a>
Ad,
Global.asax isn't a "web page", and it doesn't normally have access
to the
Request context process under which normal ASP.NET exception handling
occurs.
What exactly is it that you want to do?
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"ad" wrote:

I have set customErrors to On and set a defaultRedirect in
Web.config like:

<customErrors mode="On"
defaultRedirect ="~/ErrorPage/GenericErrorPag e.aspx">
When I throw a exception in Global.asax like:
throw new Exception("This a Error Test !!");
It will not redirect to GenericErrorPag e.aspx, but if I throw the
same Exception in other web pages, it do.

What is problem? Can't customErrors do in Global.asax?

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche

Mar 5 '06 #5
Hello ad,

I'm not Peter, by the way ;)
a> Peters,
a> Thanks again.
a> Maybe there are some condition in my program which affect the
a> redirection
a> action.
a> I will check again.
a> ad
a>
a> "Michael Nemtsev" <ne*****@msn.co m>
a> ???????:9c***** *************** ******@msnews.m icrosoft.com...
a>
Hello ad,

Hmm. strange. Could you show your code? Because <customErrors
mode="On"
defaultRedirect ="Examples.aspx "/> in Web.config and
protected void Application_Sta rt(Object sender, EventArgs e)
{
throw new Exception("my excep");
}
redirect me to the Examples.aspx page

a> Peter,
a> Thanks,
a> I want to set some application variables in Application_Sta rt, if
a> some error
a> occur, I wnat to redirect to some error page!
a> ad
a> a> "Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com >
a>
¼¶¼g©ó¶l¥ó·s»D: B8************* *************** ******@microsof t.com...
a>
Ad,
Global.asax isn't a "web page", and it doesn't normally have access
to the
Request context process under which normal ASP.NET exception
handling
occurs.
What exactly is it that you want to do?
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"ad" wrote:
> I have set customErrors to On and set a defaultRedirect in
> Web.config like:
>
> <customErrors mode="On"
> defaultRedirect ="~/ErrorPage/GenericErrorPag e.aspx">
> When I throw a exception in Global.asax like:
> throw new Exception("This a Error Test !!");
> It will not redirect to GenericErrorPag e.aspx, but if I throw the
> same Exception in other web pages, it do.
> What is problem? Can't customErrors do in Global.asax?
>


---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Mar 5 '06 #6
ad
Hello Michael,
Thanks.

ad
"Michael Nemtsev" <ne*****@msn.co m>
???????:9c***** *************** ******@msnews.m icrosoft.com...
Hello ad,

I'm not Peter, by the way ;)
a> Peters,
a> Thanks again.
a> Maybe there are some condition in my program which affect the
a> redirection
a> action.
a> I will check again.
a> ad
a> a> "Michael Nemtsev" <ne*****@msn.co m>
a> ???????:9c***** *************** ******@msnews.m icrosoft.com...
a>
Hello ad,

Hmm. strange. Could you show your code? Because <customErrors
mode="On"
defaultRedirect ="Examples.aspx "/> in Web.config and
protected void Application_Sta rt(Object sender, EventArgs e)
{
throw new Exception("my excep");
}
redirect me to the Examples.aspx page

a> Peter,
a> Thanks,
a> I want to set some application variables in Application_Sta rt, if
a> some error
a> occur, I wnat to redirect to some error page!
a> ad
a> a> "Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com >
a>
¼¶¼g©ó¶l¥ó·s»D: B8************* *************** ******@microsof t.com...
a>
> Ad,
> Global.asax isn't a "web page", and it doesn't normally have access
> to the
> Request context process under which normal ASP.NET exception
> handling
> occurs.
> What exactly is it that you want to do?
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
> "ad" wrote:
>> I have set customErrors to On and set a defaultRedirect in
>> Web.config like:
>>
>> <customErrors mode="On"
>> defaultRedirect ="~/ErrorPage/GenericErrorPag e.aspx">
>> When I throw a exception in Global.asax like:
>> throw new Exception("This a Error Test !!");
>> It will not redirect to GenericErrorPag e.aspx, but if I throw the
>> same Exception in other web pages, it do.
>> What is problem? Can't customErrors do in Global.asax?
>>


---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche

Mar 6 '06 #7

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

Similar topics

7
2863
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
1
1119
by: Dave | last post by:
Hi All, I have created a custom error page and updated the web.config file with the following element. <customErrors defaultRedirect="Errors/GenericError.aspx" mode="On" /> This appears to work fine for the majority of cases, however if an error is raised from global.asax the standard error page is displayed in place of my custom error page.
5
1492
by: vbMental | last post by:
I am deep into a project and cannot get this to work correctly. I am trying to make a custom error page that will be able to know what exception occurred. I already know about the defaultRedirect page - <customErrors mode="on" defaultRedirect="Error.aspx"/> But how do I reference the exception that occurred from that page? If I cant, then should I use the Application_Error event in global.asax ? And if I do that, then what about hiding...
9
2390
by: tshad | last post by:
I have an example I copied from "programming asp.net" (o'reilly) and can't seem to get the Sub (writefile) to execute. It displays all the response.write lines that are called directly, but not any of the response.write lines from inside the sub. ******************************************* <%@ Application Language="VB" %> <script runat="server">
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>
2
5216
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb file, and what would I do to access it? (I am using VB.NET for my code) Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
5
15157
by: ad | last post by:
The Global.asax is code-inside with default. How to change Global.asax to code-behind?
2
3717
by: Steve | last post by:
I am new to this newsgroup & to .NET in general. I have been playing around with Visual Studio .NET, building and rendering web pages using VB "code behind" files. My problem / question is; How do I ensure that changes made to the "Global.asax.vb" file are immediately reflected in the "Global.asax" file? After I change to the "Global.asax.vb" file, the "Global.asax" file date modified does not change and I do not see the updated values...
3
2330
by: Doug | last post by:
Using Visual Studio 2005, SQL Server 2000, and ASP.NET/VB.NET for a Web Application. We have a System DSN using Windows NT authentication defined on the development box to connect to the SQL Server (both SQL and IIS are on the 192.168.1.2 server). We have "Identity Impersonate=true", and "CustomErrors mode=On" and "defaultRedirect="ErrorHandler.aspx" in web.config.
0
9716
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
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...
1
10361
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10103
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
6874
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();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5676
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4316
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
3
3006
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.