473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

global.asax redirect issue

Hi all, got a bit of a strange one....I am developing in ASP.NET 2.0
and I have some code in my Session_Start method that sets user
attributes. If an error occurs at this time, such as the user is not
registered or configured for the site, I throw an error that is caught
by the Application_Error method of the global.asax file. I proceed to
get the last error information, clear it down, and then I attempt to
redirect to an error page using Response.Redirect. However, the
strange thing is that for some reason when I attempt to do this, it
results in the Session_Start being called again, which ends up putting
me in a loop as it throws the same error as before. Unfortunately I am
also integrated with CMS so using Server.Transfer is not necessarily an
option as it doesn't work right when transferring to a CMS page (which
one of our error pages is).

Has anyone ever seen this before or know why when doing a
Response.Redirect from with the Application_Error method would result
in Session_Start getting called? This type of behaviour does not occur
if the error happens anywhere else in the application or for any other
redirect that we have.

Thanks,

Jun 15 '06 #1
1 3206
Sounds like the Session cookie it not being set properly since you Session_Start
is failing and when the user makes another request the server thinks it's
a new user. Change your code from Session_Start to some other location such
that it does lazy initialization. IOW, check to see if it's been called for
this user and if not call it and store a flag that you've called it.

-Brock
http://staff.develop.com/ballen

Hi all, got a bit of a strange one....I am developing in ASP.NET 2.0
and I have some code in my Session_Start method that sets user
attributes. If an error occurs at this time, such as the user is not
registered or configured for the site, I throw an error that is caught
by the Application_Error method of the global.asax file. I proceed to
get the last error information, clear it down, and then I attempt to
redirect to an error page using Response.Redirect. However, the
strange thing is that for some reason when I attempt to do this, it
results in the Session_Start being called again, which ends up putting
me in a loop as it throws the same error as before. Unfortunately I
am also integrated with CMS so using Server.Transfer is not
necessarily an option as it doesn't work right when transferring to a
CMS page (which one of our error pages is).

Has anyone ever seen this before or know why when doing a
Response.Redirect from with the Application_Error method would result
in Session_Start getting called? This type of behaviour does not
occur if the error happens anywhere else in the application or for any
other redirect that we have.

Thanks,

Jun 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: JP | last post by:
I need to be able to trap errors at the application level. I added this code to the Global.asax file. The code I wrote is supposed to get the last error that was generated and write to the event...
5
by: vbMental | last post by:
I am deep into a project and cannot get this to work correctly. I am trying to make a custom error page that will be able to know what exception occurred. I already know about the defaultRedirect...
7
by: Jonas | last post by:
Hi! I have an Application_Error method in global.asax that uses Server.Transfer to move execution to a custom error page. This works fine when an exception is thrown in one of the aspx or ascx...
6
by: ad | last post by:
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...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
1
by: Groove | last post by:
Hey guys - I'm sure this is a commonly asked question but here goes. I'm trying to catch the error in my global.asax file and redirect to a error page which will email me the actual error upon...
3
by: kurt sune | last post by:
I have a generic errorhandler in global.asax. (in Application_Error) I need to transfer an error string from global asax to a generic error page. So I try: this code with the thought of...
0
by: daonho | last post by:
Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) Dim strPath As String = HttpContext.Current.Request.Path() Dim cookie As...
4
by: Joe | last post by:
Hello all! I added a Global.asax to my application. I'm using the Application_BeginRequest event. Everything works fine in my development enviorment but when I publish the web site the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.