3

Is there a SharePoint equivalent of the Application_Start method in a class that derives from HttpApplication, such as the default Global class that is created when you add a Global.asax to an ASP.NET project?

I want to run some code when the SharePoint Web Application starts. Or is there a different preferred way of doing this in SharePoint?

In this particular case, I would like to run some code that does some expensive calculations and caches them. So this code would run on all front-end servers in the farm.

3
  • SharePoint web application can be distributed across multiple servers. SharePoint functionality can be called not in context of web application. What problem you trying to solve? Commented Apr 12, 2011 at 11:27
  • @gandjustas In this particular case, I would like to run some code that does some expensive calculations and caches them. So this code would run on all front-end servers in the farm. Commented Apr 12, 2011 at 12:28
  • You should use timer job for this. Or Custom Service Application if calculations involves databases or external services. Commented Apr 12, 2011 at 12:33

3 Answers 3

3

Do you want the results in memory? or do you want to store them somewhere afterwards?

wouldnt mess with the Global handler approach as this is pretty complex to get right & is really hooking into the stack at the wrong level.

You want to hook in at the SharePoint Service App level by the sounds of it. This way you dont have to muck about with setup on new servers you add to the Farm etc... and its all managed through the same tools as the rest of the farm services.

3

I would suggest you move your code into a Timer Job that executes at regular intervals, in the background. Running stuff when the application starts will only slow down it further (we all know that SharePoint is a bit tired in the morning). Timer Jobs can be set to execute at specific intervals or times and can be run on specific or all servers.

Check out AC's post on the topic: http://www.andrewconnell.com/blog/archive/2007/01/10/5704.aspx (it's for MOSS 2007 but it's basically the same for 2010)

1

This will depend on what you want to achieve. One way would be to hook up a custom module.

Example http://www.sharepoint4arabs.com/AymanElHattab/Lists/Posts/Post.aspx?List=0b2c413e%2De6fb%2D4c60%2Da12f%2D9ae9bdbd48c8&ID=62

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.