When working with the Global.asax file, even though the question is inheriting from Sitecore.ContentSearch.SolrProvider.NinjectIntegration.NinjectApplication
, if you keep digging down, eventually you'll find that also inherits from the HttpApplication
class. Ordinarily, this class exists in the System.Web namespace.
However, when choosing protected as your access modifier, what you are really saying is that the method is only available if subclassed. See this chart below for an visual on how the different access modifiers affect based on how the method is being accessed.
| highest precedence <---------> lowest precedence
*———————————————+————————————————+———————————+———————————————+———————
\ xCanBeSeenBy | this | any class | this subclass | any
\__________ | class | in same | in another | class
\ | nonsubbed | library | library | any
Modifier of x \ | | | | library
————————————————*————————————————+———————————+———————————————+———————
public | ✔ | ✔ | ✔ | ✔
————————————————+————————————————+———————————+———————————————+———————
protected | ✔ | ✔ | ✔ | ✘
————————————————+————————————————+———————————+———————————————+———————
internal | | | |
(no modifier) | ✔ | ✔ | ✘ | ✘
————————————————+————————————————+———————————+—————————-—————+———————
private | ✔ | ✘ | ✘ | ✘
(chart citation)
When Application_Start
is being called, it's actually being called from outside the subclass or class namespace, and thus must be visible to any class.
By protecting the method, you are essentially saying that it is only available to any class that inherits from your version of the Global
class, or within the same package, or within the same class. This is why your method wasn't firing.
Resolution
Change protected
to public
as shown below:
public class Global : Sitecore.ContentSearch.SolrProvider.NinjectIntegration.NinjectApplication
{
public void Application_Start(Object sender, EventArgs e)
{
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Log.Info("Now Using Tls12 SecurityProtocol", this);
}
}
Additional Fun Fact
In version 8.2 of Sitecore, the Global.asax has been set to inherit from Sitecore.Web.Application
. Furthermore, Application_Start()
has been made internal so that it can not be overridden.