Wrox Programmer Forums
|
BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Special Edition by Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muhammad, Srinivasa Sivakumar; ISBN: 9780470041789
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 17th, 2012, 05:05 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Can you provide a bit more information about your actual setup? E.g. what type of web application and module, and how you're calling this code and when?

The code by itself should run fine, provided that HttpContext is available, so it must be the way this code is called that's causing the problem.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old February 17th, 2012, 05:33 AM
Registered User
 
Join Date: Feb 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Its a web application, 3 tiered architecture: Backend/Database (Oracle 11g), Application Core (vb.net classes and modules), and Interface (ASP.NET 4.0).

The application core does not have any ASP.Net code, its purely VB.Net namespaces that implements how the application interfaces with the database, it also has the data classes. I have a general error handler module (by module I mean a vb module file not subsystem, so that the core can call the error handling methods without fully qualified names) to handle the application errors and log proper messages in the database, then would "redirect" the user to the application Error page (ASP.Net).

They are in different folders, folder Structure:
1- The ErrorPage.aspx is in the application root folder
2- modErrorHanlder.vb is in \Core

This pretty much describes the setup and flow. Is this sufficient to help you help me?

Thanks
Jafar
 
Old February 17th, 2012, 09:19 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Could it be that the error handler is called for situation outside of the user context? E.g. at places where there is no current Request? This could be the case for errors in Application_Start for example.

Can you test for HttpContext.Current being Nothing?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old February 20th, 2012, 09:44 AM
Registered User
 
Join Date: Feb 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi,

reading your reply made me do the following test:
1- I explicitly invoked my module.ShowErrorPage from my Default.aspx load event, and it worked fine
2- then I redid the scenario (described in my previous posts), in which the ShowErrorPage is being invoked from a data class method which was called from an ASP.Net page code behind page, and this time it did redirect me to the errorpage (to be honest I am not sure if this was always the case or not, last week I was debugging it and as soon as I get the exception I would stop the program) but I also still got the "unable to evaluate expression" exception on the Redirect line? I am passing the error message via the session, would that have anything to do with it?

To answer your question, in both 1 and 2, the HttpContext.Current had a value.

"Could it be that the error handler is called for situation outside of the user context? E.g. at places where there is no current Request? ": the calls for ShowErrorPage come from ASP.Net pages or the data classes, but all the ones from the data classes, initially comes from ASP.Net pages, wouldnt this mean that there always should be a request?

Thanks
Jafar

Last edited by JafarKofahi; February 20th, 2012 at 09:49 AM..
 
Old February 22nd, 2012, 02:04 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
initially comes from ASP.Net pages, wouldnt this mean that there always should be a request?
Yes, when executed from an ASPX page, there should be an HttpContext.

Does the error only happen in the debugger or at run-time as well?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old February 23rd, 2012, 10:57 AM
Registered User
 
Join Date: Feb 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Yes it happens at runtime and when debugging

Jafar
 
Old February 28th, 2012, 03:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Not sure why this wouldn't work. Sorry...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
JafarKofahi (February 28th, 2012)
 
Old February 28th, 2012, 07:01 PM
Registered User
 
Join Date: Feb 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thats fine..thanks for your time





Similar Threads
Thread Thread Starter Forum Replies Last Post
response.redirect sarah lee ASP.NET 1.0 and 1.1 Basics 1 October 27th, 2006 08:57 AM
response.redirect ava_h .NET Framework 2.0 0 October 18th, 2006 10:21 PM
Response.Redirect + Javascript jfergy Classic ASP Basics 2 January 17th, 2006 09:17 PM
response.redirect crmpicco Classic ASP Basics 3 February 9th, 2005 01:50 AM
Response.Redirect dhborchardt Classic ASP Basics 4 June 16th, 2003 05:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.