Solved

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

Posted on 2006-06-29
5
2,031 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
Comment Utility
use alert java script function
0
 

Author Comment

by:LloydMc
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

17 Experts available now in Live!

Get 1:1 Help Now