Can't customErrors do in Global.asax

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

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

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

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

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

What is problem? Can't customErrors do in Global.asax?
 
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
 
Peter,
Thanks,
I want to set some application variables in Application_Start, if some error
occur, I wnat to redirect to some error page!


ad
 
Hello ad,

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

protected void Application_Start(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_Start, if
a> some error
a> occur, I wnat to redirect to some error page!
a> ad
a>
a> "Peter Bromberg [C# MVP]" <[email protected]>
a> ¼¶¼g©ó¶l¥ó·s»D:[email protected]...
a>---
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
 
Peters,
Thanks again.
Maybe there are some condition in my program which affect the redirection
action.
I will check again.

ad


Michael Nemtsev said:
Hello ad,

Hmm. strange. Could you show your code? Because <customErrors mode="On"
defaultRedirect="Examples.aspx"/> in Web.config and
protected void Application_Start(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_Start, if
a> some error
a> occur, I wnat to redirect to some error page!
a> ad
a> a> "Peter Bromberg [C# MVP]" <[email protected]>
a> ¼¶¼g©ó¶l¥ó·s»D:[email protected]...
a>---
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
 
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" <[email protected]>
a> ???????:[email protected]...
a>
Hello ad,

Hmm. strange. Could you show your code? Because <customErrors
mode="On"
defaultRedirect="Examples.aspx"/> in Web.config and
protected void Application_Start(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_Start, if
a> some error
a> occur, I wnat to redirect to some error page!
a> ad
a> a> "Peter Bromberg [C# MVP]" <[email protected]>
a>
¼¶¼g©ó¶l¥ó·s»D:[email protected]...
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
:
I have set customErrors to On and set a defaultRedirect in
Web.config like:

<customErrors mode="On"
defaultRedirect="~/ErrorPage/GenericErrorPage.aspx">
When I throw a exception in Global.asax like:
throw new Exception("This a Error Test !!");
It will not redirect to GenericErrorPage.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
 
Hello Michael,
Thanks.

ad


Michael Nemtsev said:
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" <[email protected]>
a> ???????:[email protected]...
a>
Hello ad,

Hmm. strange. Could you show your code? Because <customErrors
mode="On"
defaultRedirect="Examples.aspx"/> in Web.config and
protected void Application_Start(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_Start, if
a> some error
a> occur, I wnat to redirect to some error page!
a> ad
a> a> "Peter Bromberg [C# MVP]" <[email protected]>
a>
¼¶¼g©ó¶l¥ó·s»D:[email protected]...
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
:
I have set customErrors to On and set a defaultRedirect in
Web.config like:

<customErrors mode="On"
defaultRedirect="~/ErrorPage/GenericErrorPage.aspx">
When I throw a exception in Global.asax like:
throw new Exception("This a Error Test !!");
It will not redirect to GenericErrorPage.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top