I want to execute a piece of code on application start. As application_start not available in share point, so i have written my own custom HTTPModule and in Init method i have written the code. But the problem here is, the Init method is calling multiple times and the same code executing several times. I want to execute the code only once.
I have used lock mechanism code suggested from http://stackoverflow.com/questions/1140915/httpmodule-init-method-is-called-several-times-why After writing the lock mechanism code in HTTPModule, when i browse the site pages which has web parts then i am getting NULLRefernece Exception. If i remove the lock mechanism code, its working fine.
can you please suggest me how to execute the Init code only once.