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

Forums / Developing with Sitefinity / Global.asax file is not working

Global.asax file is not working

2 posts, 0 answered
  1. Alma
    Alma avatar
    1 posts
    Registered:
    06 Sep 2013
    30 Oct 2013
    Link to this post
    Hi,

    We are trying to merge the publish code of an asp.net application with sitefinity cms app. After merging the code, the code written in Global.asax file in asp.net app stop working due to which URL rewriting and error handling concept given in Global.asax file fails. Kindly suggest how could we fix this.

    Thanks in advance.
  2. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    30 Oct 2013 in reply to Alma
    Link to this post
    Alma,

    If you have sample code we can try and help you some more.  But here is a successful global file we use.  Hopefully this helps!  Make sure you are building your solution after you modify your Global.asax.

    using System;
    using Aptera.Widgets.Configurations;
    using Telerik.Sitefinity.Configuration;
    using Telerik.Sitefinity.GenericContent.Model;
    using Telerik.Sitefinity.Modules.ControlTemplates;
    using Telerik.Sitefinity.Modules.Pages;
    using SitefinityWebApp.App_Code;
     
    namespace SitefinityWebApp
    {
        public class Global : System.Web.HttpApplication
        {
     
            protected void Application_Start(object sender, EventArgs e)
            {
                Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
            }
     
            void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
            {
                if (e.CommandName == "Bootstrapped")
                {
                    CreateWidgetTemplates();
                    Config.RegisterSection<CalloutConfig>();
                    Config.RegisterSection<FormsAskimetCredentials>();
                }
     
                Telerik.Sitefinity.Scheduling.SchedulingManager schedulingManager = Telerik.Sitefinity.Scheduling.SchedulingManager.GetManager();
                string myKey = "RecurringScheduledTask";
                SitefinityWebApp.App_Code.RecurringScheduledTask newTask = new SitefinityWebApp.App_Code.RecurringScheduledTask()
                {
                    Key = myKey,
                    ExecuteTime = DateTime.UtcNow.Subtract(TimeSpan.MaxValue),
                };
                schedulingManager.AddTask(newTask);
                schedulingManager.SaveChanges();
            }
     
            void CreateWidgetTemplates()
            {
                PageManager pageManager = PageManager.GetManager();
                ControlTemplates.RegisterTemplatableControl(typeof(Aptera.Widgets.Callout), typeof(ContentItem), null, "Callouts", "Callouts");
                pageManager.SaveChanges();
            }
     
            protected void Session_Start(object sender, EventArgs e)
            {
     
            }
     
            protected void Application_BeginRequest(object sender, EventArgs e)
            {
     
            }
     
            protected void Application_AuthenticateRequest(object sender, EventArgs e)
            {
     
            }
     
            protected void Application_Error(object sender, EventArgs e)
            {
     
            }
     
            protected void Session_End(object sender, EventArgs e)
            {
     
            }
     
            protected void Application_End(object sender, EventArgs e)
            {
     
            }
        }
    }
2 posts, 0 answered