473,385 Members | 1,925 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,385 software developers and data experts.

Response.Redirect in Application_Start & Session_Start

csn
Is it possible to have a Response.Redirect in Global.asax in the
Application_Start and Session_Start events?

We have code in both events, with try-catch blocks, and if an exception is
caught, we wanted to redirect to an error page. But, this doesn't seem to
work.

So, another question is, if an exception is thrown and caught in a catch
block in Application_Start and/or Session_Start, what do we or can we do
with it?

Thanks.
Nov 19 '05 #1
4 6607
You can't do this.
The Application_Start event is not associated with any user, therefore you
cannot redirect a user from it.
If I caught an exception in there I'd probably log it.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"csn" <cs*@nospam.com> wrote in message
news:e7*************@TK2MSFTNGP09.phx.gbl...
Is it possible to have a Response.Redirect in Global.asax in the
Application_Start and Session_Start events?

We have code in both events, with try-catch blocks, and if an exception is
caught, we wanted to redirect to an error page. But, this doesn't seem to
work.

So, another question is, if an exception is thrown and caught in a catch
block in Application_Start and/or Session_Start, what do we or can we do
with it?

Thanks.

Nov 19 '05 #2
You can't do this.
The Application_Start event is not associated with any user, therefore you
cannot redirect a user from it.
If I caught an exception in there I'd probably log it.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"csn" <cs*@nospam.com> wrote in message
news:e7*************@TK2MSFTNGP09.phx.gbl...
Is it possible to have a Response.Redirect in Global.asax in the
Application_Start and Session_Start events?

We have code in both events, with try-catch blocks, and if an exception is
caught, we wanted to redirect to an error page. But, this doesn't seem to
work.

So, another question is, if an exception is thrown and caught in a catch
block in Application_Start and/or Session_Start, what do we or can we do
with it?

Thanks.

Nov 19 '05 #3
re:
Is it possible to have a Response.Redirect in Global.asax
in the Application_Start and Session_Start events?
The Application_OnStart event occurs before the first
new session is created, before the Session_OnStart event.

Only the Application and Server built-in objects
are available within Application_OnStart.

Referencing the Session, Request, or Response objects
in the Application_OnStart event script causes an error.

However, all the built-in objects are available and
can be referenced in the Session_OnStart event script.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"csn" <cs*@nospam.com> wrote in message
news:e7*************@TK2MSFTNGP09.phx.gbl... Is it possible to have a Response.Redirect in Global.asax in the
Application_Start and Session_Start events?

We have code in both events, with try-catch blocks, and if an exception is
caught, we wanted to redirect to an error page. But, this doesn't seem to
work.

So, another question is, if an exception is thrown and caught in a catch
block in Application_Start and/or Session_Start, what do we or can we do
with it?

Thanks.

Nov 19 '05 #4
re:
Is it possible to have a Response.Redirect in Global.asax
in the Application_Start and Session_Start events?
The Application_OnStart event occurs before the first
new session is created, before the Session_OnStart event.

Only the Application and Server built-in objects
are available within Application_OnStart.

Referencing the Session, Request, or Response objects
in the Application_OnStart event script causes an error.

However, all the built-in objects are available and
can be referenced in the Session_OnStart event script.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"csn" <cs*@nospam.com> wrote in message
news:e7*************@TK2MSFTNGP09.phx.gbl... Is it possible to have a Response.Redirect in Global.asax in the
Application_Start and Session_Start events?

We have code in both events, with try-catch blocks, and if an exception is
caught, we wanted to redirect to an error page. But, this doesn't seem to
work.

So, another question is, if an exception is thrown and caught in a catch
block in Application_Start and/or Session_Start, what do we or can we do
with it?

Thanks.

Nov 19 '05 #5

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

Similar topics

2
by: Jeanne Louw | last post by:
Hi Why would this happen? The Application_Start and Session_Start events fires on each page request on my website. SessionID stays the same between page requests. <sessionState mode="InProc"...
6
by: Ober | last post by:
I'm having trouble with my security model, Application_Start, and accessing my database. My ASP.NET app is only going to be running in an intranet environment (not on the public Internet). ...
0
by: csn | last post by:
Is it possible to have a Response.Redirect in Global.asax in the Application_Start and Session_Start events? We have code in both events, with try-catch blocks, and if an exception is caught, we...
7
by: Gordon Smith | last post by:
I have four (4) ASP.NET Web applications/Web sites on a IIS/6 - Windows Server 2003 production server. 3 of them work fine. I just installed the 4th one and it's Application_Start event is not...
0
by: SeanGallavan | last post by:
Our Environment: Two network load balanced (using Microsoft NLB software) webservers with session maintained in a SQL Server database. NLB is configured with no affinity settings and two...
6
by: Joe Befumo | last post by:
I just created the default personal site project in Visual Studio 2005, and it worked perfectly -- very nice. Next, I'd like to import some stat-capture code that I have working in a Visual Studio...
2
by: Mark Rae | last post by:
Hi, I have a fairly simple site, the vast majority of which is available to everyone on the public internet. However, the site has one section which requires logon via the standard...
4
by: =?Utf-8?B?bWFzbWl0aA==?= | last post by:
Can you restart an ASP.NET application in the Application_Start event when an error occurs so the next request for the application will fire the Application_Start event again? This would allow...
0
by: dhanashivam | last post by:
Hi all, In my application i used a session variables which is declared in the session_start of the global.asax. This session varaible is assigned by a new value and login page. this session value...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.