Solved

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

Posted on 2006-06-29
5
2,239 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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