1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Bootstrapper question

Bootstrapper question

2 posts, 1 answered
  1. Pavel Donchev
    Pavel Donchev avatar
    14 posts
    Registered:
    30 Nov 2008
    22 Oct 2011
    Link to this post

    Hey guys!
    Just noticed that the bootstrapper raises the Initialized Event twice (at least in my case) I saw few examples where this event is used as if it will rise just once. So I was wondering if I am doing something wrong?
    The code is fairly simple:

    protected void Application_Start(object sender, EventArgs e)
    {
        Bootstrapper.Initialized += new EventHandler<ExecutedEventArgs>(OnSitefinityAppInitialized);
    }

    Then in the Initialized event handler we have some other work:

    private void OnSitefinityAppInitialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
    {
     
    }

    I noticed that if I check the args.CommandName, the first time it is rised it is set to "RegisterRoutes" and the next time it is "Bootstrapped", I used a simple if to check if the event is rised for "Bootstrapped" so my code works, I was just wondering if it is a good practice to check if the command name is "Bootstrapped".

    Thanks in advance!

  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    26 Oct 2011
    Link to this post
    Hello Pavel,

    Thank you for contacting us.

     You are correct that the Event is fired twice. Indeed, it is a good practice to check the command inside the handler, so that you can prevent your code from being executed twice.

    Let me know if I can help you with something else.

    All the best,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
2 posts, 1 answered