global-asax

What's the best way to load highly re-used data in a .net web application

Let's say I have a list of categories for navigation on a web app. Rather than selecting from the database for evey user, should I add a function call in the application_onStart of the global.asax to fetch that data into an array or collection that is re-used over and over. If my data does not change at all - (Edit - very often), would...

ASP.Net Session_Start event not firing

I have an ASP.Net 2.0 application in which the Session_Start event is not firing in my Global.asax file. Can anyone tell why this is happening and how I can get it working? The application worked fine on my Windows XP development machine, but stopped working when deployed to the server (Win Server 2003/IIS 6/ASP.Net 2.0). I'm not sure...

How can you hook a SharePoint 2007 feature into the Application_Start of a site?

Hello, I was wondering if there is a good way to hook into the Application_Start of a SharePoint 2007 site when developing a feature? I know I can directly edit the Global.asax file in the site root, but is there a way to do this so that it gets deployed with the feature? Thanks! ...

log4net with ASP.NET 3.5 problems

I'm having some trouble getting log4net to work from ASP.NET 3.5. This is the first time I've tried to use log4net, I feel like I'm missing a piece of the puzzle. My project references the log4net assembly, and as far as I can tell, it is being deployed successfully on my server. My web.config contains the following: <configSections...

Remove or change Default Route post Global.asax

I'm building a CMS in ASP.NET MVC and want to allow users to pick which page they want to be displayed by default when the user first visits the site. I set my default route in Global.asax, like so (for example): routes.MapRoute( "Default", // Route name "{co...

Application_Start works fine on workstation, is not called when deployed

I have an application that works great on my development workstation but fails when the application is deployed to the live environment. It seems that Application_Start is not being called in the live environment. ...

SharePoint and deployment of global.asax code

I want to start logging some custom messages into the ULS from my custom SharePoint code. My code is running inside list item receivers attached to some lists. I'd like to configure this logging mechanism within the application start event handler in global.asax. What's the best-practices way to deploy a SharePoint solution package th...

Global.asax and handling exceptions that occur in spawned Threads

I have an exception handler . In my asp.net application. It’s written in Global.asax. In the the Application_Error() method. It works for Exceptions that happen in the context of pages and classes that are called as a result of a request to the application. But if I spawn a thread, as a result of a request (or other reason, like an ap...

How do I access properties from global.asax in some other page's code behind

Imagine I have a property defined in global.asax. public List<string> Roles { get { ... } set { ... } } I want to use the value in another page. how to I refer to it? ...

Error accessing the Cache in the Application_Start method of Global.asax

I am trying to access the Cache in the Application_Start method of Global.asax. I am trying to accdess Context.Cache. When I run the code from visual studio it works just fine but when I run it on the server from IIS I get: Session state is not available in this context. I want to seed some values in the cache when the application starts...

ASP.NET MVC can't find route programatically

Hi folks, I have the following one route, registered in my global.asax. routes.MapRoute( "Home", // Unique name "", // Root url new { controller = "Home", action = "Index", tag = string.Empty, page = 1 } ); kewl. when i start the site, it correctly picks up this route. Now, when i try to programatically do the f...

Application_End global.asax

Can anybody tell me when Application_End is triggered in a lifecycle of an application? When all sessions are ended, will Application_End be triggered automatically? + Are there any other reasons why Application_End could be triggered? Thx. ...

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 image page is loaded the System.Web.HttpContext.Current.Session is null in global.asax which...

IIS Recycle Global.asax

Is it possible to catch an recycle event in the global.asax? I know Application_End will be triggered but is there a way to know that it was triggered by a recycle of the application pool? thx, Lieven Cardoen aka Johlero ...

accessing SessionState in Global.Application_Error

In the Application_Error method in Global.asax I am trying to retrieve a value from session state. I am able to access session state as long as I throw the exception. EG: thow new Exception("Test exception"); However if it is an unhandled exception, i get the following error when trying to access session state: "Session state is not...

what alternatives are there to using global.asax?

I am using my own custom authentication with IIS, and I want the server on every page load (no matter what type of file) to first check the Application variable to see if the user is authenticated and authorized to see the site. In global.asax this could be: void Application_Start(Object Sender, EventArgs e) { if(Application["username...

Why does global.asax change sql connection?

In asp.net 3.5, I have a problem that if I upload my global.asax to the remote web server, the app starts looking for my local sql server and eventually times out. I use a different config file for the local and remote because of the sql server login. Local is windows auth and remote is sql server auth. However, none of that info is ...

What is the class System.Web.httpApplicationFactory? I see it in my call stack, but can't find it in the framework.

I have a class Application that my global.asax inherits from. The class has this method: protected void Application_Start(object sender, EventArgs e) { // ... } In my understanding this is basically an event handler that is automatically added to an event (based on the method name [*]). I tried to find out what event exactly, so I...

Get Session start information if Session is turned off in ASP .NET

I have an ASP .NET information and I currently have session state turned off so I can't exactly hook into the session start event within the Global.asax. I want to get at this data, when someone comes to a site, and when they would normally start a session. What is the event that is fired to start a session so that I could hook into it a...

Why won't VS 2008 SP1 let me edit global.asax?

Normally I create web application projects and use code-behind, but I have a requirement to create an small throwaway demo app using code-inline. I added a global.asax file to the app, but for some odd reason, Visual Studio 2008 SP1 won't let me edit any of the code between the script tags i.e. add code to the event handlers such as App...