Search code examples
servicestackhost

How to configure AppHostBase virtual methods?


AppHostBase has two overridable methods where you can configure your inherited Application host

  • Init()
  • Configure(Container container)

Is there a rule to know which is better?

For instance:

  • Container.RegisterAs<SmtpEmailer, IEmailer>().ReusedWithin(ReuseScope.Request);
  • OrmLiteConfig.CommandTimeout = 120;
  • Container.RegisterValidators(typeof(CustomerService).Assembly);
  • Plugins.Add(new SeqRequestLogsFeature(new SeqRequestLogsSettings(AppSettings.GetString("SeqUrl"))));

Is it better to call these lines on Init() or Configure() or it depends?


Solution

  • All ServiceStack Configuration should be maintained in AppHost.Configure() which is also the only abstract method which every AppHost needs to override.