Solved

How to display an popup error message from the global.asax file

Posted on 2006-06-29
5
2,096 Views
Last Modified: 2012-06-27
Hello all,

I'm handling unexpected exceptions in the Global.asax's Application_Error event.  The current code in the Application_Error event gathers the exception info and notifies the dev staff, then redirects the user to an friendly error page with a link to the application's home page. The issue I'm having is that there is a process which opens a page in a new window where additional processing occurs.  If an exception occurs in the new window, the home page redirection, of course, takes place from that point. What I would like to do is open the error page in a separate window via jscript, but this doesn't seem possible from global asax.  Any suggestions would be appreciated.
0
Comment
Question by:LloydMc
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17010664
use alert java script function
0
 

Author Comment

by:LloydMc
ID: 17010885
Zaghaghi,

How would I do this? I can't inject any script from global.asax since I don't have access to the response object.
0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17010991
when you cath the errors in global.asax you can redirect to a page that shows error(s)

why do you need to display an popup error?
0
 

Author Comment

by:LloydMc
ID: 17011100
Zaghaghi,

As I explained above, there is a process that executes in a page that was opened in a separate window, so if an exception occurs in that window, any navigation will occur in that window's space, leaving the previous window open in the background. Also, I don't want to navigate away from the current page.
0
 
LVL 5

Accepted Solution

by:
vinodhsomasekharan earned 250 total points
ID: 17016552

Hai.
In Application_Error() event of global.asax page
if your objective is to redirect to another aspx page then u can
  use response.redirect or server.transfer
eg.. Server.Transfer("../DataGrid/DataGridSample1.aspx", True)

if u want to use a javascript function to redirect to another aspx page then u can try this

        HttpContext.Current.Response.Write("<html><script language='javascript'>alert('error comes here');window.location.href='../DataGrid/DataGridSample1.aspx';</script></html>")
        Server.ClearError()
Note: just save u r error message in a session varible or pass it as an argument to the new page before giving server.clearerror() else u might loose the error details...
eg: HttpContext.Current.Session("hh") = Server.GetLastError.GetBaseException.Message

Hope it helps u,

Regards
Vinodh


       
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP:DataGrid and how to bind to a BoundColumn 8 38
Two different visual studio versions 3 22
Split in Javascript 5 31
Code works but it's slow 24 40
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now