Questions tagged [global-asax]

A special file in the ASP.NET framework, it provides a simplified interface to create hooks into system events in the life cycle of a web application and web pages in that application.

A special file in the ASP.NET framework, it provides a simplified interface to create hooks into system events in the life cycle of a web application and web pages in that application.

Most often used to define resources which need to be globally defined for use by all web pages and services.

1047 questions
19
votes
2 answers

.NET Application_BeginRequest - How to get User reference?

I'm trying to get a reference to the user object in my Global.asax file's Application_BeginRequest. I'm using the property Context.User but I get a NullReferenceException. Is it possible to get a user object reference in Application_BeginRequest?
Ropstah
  • 17,538
  • 24
  • 120
  • 194
19
votes
1 answer

Global.asax - Application_Error - How can I get Page data?

I have this code: using System.Configuration; void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError().GetBaseException(); string ErrorMessage = ex.Message; string StackTrace = ex.StackTrace; …
Ash
  • 1,269
  • 3
  • 25
  • 49
18
votes
4 answers

When's the earliest i can access some Session data in global.asax?

i want to check if the Session contains some key/value data, in my global.asax. I'm not sure when the earliest possible time (and method name) is, to check this. thanks :)
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
17
votes
6 answers

global.asax breakpoint not hit

I have some code in my ASP.NET app in C# that's in the Global.asax.cs code file. In the Application_Start, Session_Start and Application_Begin Request I have set some breakpoints. However none of these are ever hit. I'm working on my local machine…
user259286
  • 977
  • 3
  • 18
  • 38
17
votes
1 answer

Class in App_Code not accessible by Global.asax.cs

I've created a new class in App_Code namespace Site { public class MyClass { public MyClass() { } } } this is my Global.asax.cs namespace Site { public class Global : System.Web.HttpApplication { protected void…
acermate433s
  • 2,514
  • 4
  • 24
  • 32
17
votes
2 answers

Why HttpContext.Current.Session is null in Global.asax?

I'm using VS2010 and created a simple asp. web forms application, using Development Server to test it. I try to store user data - queried from sql server - in the session, since I don't want to access database in every request. I'm using the…
Péter
  • 2,161
  • 3
  • 21
  • 30
17
votes
4 answers

global.asax Application_Error not firing

My global.asax seems not to be firing. I have: void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs Server.Transfer("~/ExceptionFormView.aspx"); } In my web.config, I don't have anything…
17
votes
4 answers

Global.asax parse error after minor change and revert to previous version

The project in context is: ASP .NET Web Application .NET Framework: 4 Platform Target: x86 IDE: Visual Studio 2010 Ultimate SP1 Multiple projects in solution with ASP .NET being the startup project. It has been in production for months without…
Raheel Khan
  • 14,205
  • 13
  • 80
  • 168
16
votes
4 answers

ASP.NET MVC doesn't call global.asax' EndRequest

I am trying to perform some actions at the end of every request. I changed the Application_Start() that is generated when created new project to make a test: protected void Application_Start() { EndRequest += (s, e) => { …
user87338
  • 361
  • 2
  • 4
  • 10
16
votes
3 answers

ASP.NET: Is it possible to call async Task in Global.asax?

I need to call some async operations on my DB in Global.asax. for example in Application_AuthenticateRequest I need to Authenticate user against DB Is it possible with async Tasks?
user1328761
  • 161
  • 1
  • 5
15
votes
10 answers

System.EnterpriseServices.Wrapper.dll error

Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Could…
Elaine
  • 1,288
  • 5
  • 17
  • 35
15
votes
1 answer

how many times is System.Web.HttpApplication is initialised per process

I have the global.asax which extends from a custom class I created, called MvcApplication which extends from System.Web.HttpApplication. In it's constructor, it logs application start as per below: protected MvcApplicationGeneral() { …
Karl Cassar
  • 6,043
  • 10
  • 47
  • 84
14
votes
4 answers

How to handle session end in global.asax?

I'm working in chat application, I used HashTable for containing User and Operator as a Key & Object of ChatRoom Class as a value of HashTable. Main problem is that When user or Operator close browser or disconnected without logout then It is…
ashish bhatt
  • 3,091
  • 5
  • 25
  • 23
14
votes
1 answer

BeginRequest-like filter in MVC 3?

I have some code in my application that I need to execute on every request, before anything else executes (even before authentication). So far I've been using the Application_BeginRequest event in my Global.asax, and this has worked fine. But this…
Daniel Liuzzi
  • 16,807
  • 8
  • 52
  • 57
14
votes
4 answers

Asp.net System.Web.HttpContext.Current.Session null in global.asax

I have a custom security principal object which I set in the global.asax for the current thread and all is well, no problems normally. However, I'm just adding a dynamic image feature by having a page serve up the image and whenever that dynamic…
JohnC
  • 3,938
  • 7
  • 41
  • 48
1
2
3
69 70